Click to See Complete Forum and Search --> : How to run a command at cmd line?
laudy
Nov 29th, 1999, 08:43 PM
I am very new to VB. In VBscript, I am able to run commands (regsvr32.exe /s /c ... regedit -s ... net stop... etc.) in a hidden cmd.exe window using WSH and creating a ("wscript.shell") object and passing whatever the command is to a little sub.
How can I run a program like cmd.exe in a hidden window and wait till it finishes execution to return to the VB app? (I need to stop services, register Dlls, and install registry keys.) Thanks.
john_murphy
Nov 30th, 1999, 08:10 PM
Got this from the help hope this is what you want.
john_m_murphy@hotmail.com
Co Galway, Ireland
' In Microsoft Windows:
' Specifying 0 as the second argument opens the application in
' hidden size and gives it the focus.
RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator.
Here are the constants
Constant Value Description
vbHide 0
Window is hidden and focus is passed to the hidden window.
vbNormalFocus 1
Window has focus and is restored to its original size and position.
vbMinimizedFocus 2
Window is displayed as an icon with focus.
vbMaximizedFocus 3
Window is maximized with focus.
vbNormalNoFocus 4
Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus 6
Window is displayed as an icon. The currently active window remains active.
laudy
Nov 30th, 1999, 08:59 PM
Thanks for the reply! That helps me out very much.
Another quick question for anyone...
Would anyone know how to pass a command to the external program?
--Say you wanted to stop the Alerter service in NT and you wanted to run "net stop "Alerter" from the command prompt in a hidden command window.
--How could you pass "net stop Alerter" to
Shell("cmd.exe" , 0) ??
Thanks for any thoughts on this!
laudy
Dec 1st, 1999, 03:06 AM
In case anybody cares....
You can use:
Shell("cmd.exe /c <whatever command you want to run from a command prompt here>")
To send a command to cmd.exe...
Example:
Shell("cmd.exe /c net stop w3svc")
(to stop web publishing service)
Im sure this is the clunkiest way to do this, but what do I know? <nothing>
gsc1ugs
Apr 23rd, 2002, 06:16 AM
Is it possible to track thethreads of this?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.