Diverse
Hiding cmd window
Prevent VBscript app from showing Console Window
objShell.Run "cmd /c yourcommands", 0, True
Run a batch file in a completely hidden way
Solution 1:
Save this one line of text as file invisible.vbs:
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
To run any program or batch file invisibly, use it like this:
wscript.exe "C:\Wherever\invisible.vbs" "C:\Some Other Place\MyBatchFile.bat"
To also be able to pass-on/relay a list of arguments use only two double quotes
CreateObject("Wscript.Shell").Run "" & WScript.Arguments(0) & "", 0, False
Example: Invisible.vbs "Kill.vbs ME.exe"
Why 4 double quotes, could you please explain?
VB syntax. & means concatenate strings. Strings are enclosed in double quotes (").
Consecutive double quotes ("") inside string delimiters means a literal double quote (").
So, four double quotes ("""") would be a string literal of one character, a double quote (").
Put it together, and """" & WScript.Arguments(0) & """" would become "<argument>",
where <argument> is the first command line argument passed to the script.
Doesn't this still require you to create a batch file for putting the wscript.exe "C:\Wherever\invisible.vbs" ... inside of?
Solution 2:
Use a command line tool to silently launch a process: Quiet, hidecon or hideexec.
Quiet
This tool is a real quick and dirty program that I whipped up in about 5 minutes (took longer to set compiler options than write the code) which uses ShellExecuteEx to spawn a "detached" process. It is actually just a hidden process that doesn't appear on the task bar but it does appear in task manager or anything that enumerates processes. I wrote it because of a post in microsoft.public.win2000.cmdprompt.admin. Simply specify quiet "command" and it will run whatever it is hidden. If the program doesn't exist it will pop a dialog box which is annoying but if the program is in the path somewhere it will execute it. Please note that logging off will kill the process as it may be hidden from the user but it isn't hidden from the system.
hideexec
hideexec seems to have some difficulties to run elevated commands
Hide command window on batch file
How Can I Hide the Command Window When Executing a Command Like net Localgroup Administrators?
Set objShell = CreateObject("Wscript.Shell")
strCommand = "net localgroup Administrators"
Set objExec = objShell.Exec(strCommand)
Do Until objExec.Status
Wscript.Sleep 250
Loop
Wscript.Echo objExec.StdOut.ReadAll()