How to Run Console Programs Without a Console Window
From time to time the question gets asked how a batch file or console program can be executed silently or hidden, i.e. without a console window popping up. If you do not know what I am talking about: press Win+R, type “help” and press ENTER. A black console window will open, execute the HELP command and close again. Often, this is not desired. Instead, the command should execute without any visible window.
Solution 1: For Programmers
Use CreateProcess to execute the command and set the parameter dwCreationFlags to CREATE_NO_WINDOW (0x08000000).
Solution 2: For Script Writers
Use the Run method as illustrated in the following code snippet to execute the command:
Set Shell = CreateObject("WScript.Shell")
Shell.Run """Path to command or batch file""", 0, False
Of the three arguments to Run, the first is the full path to the executable or batch file, the second sets the windows style (0 meaning “hide the window”) and the third specifies whether the script waits for the command to return (False meaning “no, do not wait”).
Solution 3: For Everybody Else
Use the excellent little free tool hstart. It is not only capable of executing any command without a visible console window but is a full-fledged replacement of the console’s START command – and more. For example, it handles Vista UAC elevation and it is even available in a 64-bit version.
1 Comment
Great! Thank you, first time I read about this tool!