How to Run Console Programs Without a Console Window

  • Scripting
  • Published Aug 15, 2008 Updated Oct 27, 2010

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.

Comments

Related Posts

Blocking Office Macros, Managing Windows & macOS via Intune

Blocking Office Macros, Managing Windows & macOS via Intune
How to centrally manage essential security settings of self-managed devices This is a guest post by Martin Kretzschmar, customer success engineer at vast limits, the uberAgent company. One thing I especially like about my everyday working life is the flexibility it offers. I appreciate the freedom of choice in terms of location, time and device. We want to avoid getting into micro-management but, being an IT company, we also need to provide the necessary security where needed.
Scripting

Latest Posts

Filebrowser to Be Archived. Migrate to a Modern Alternative: Sambee

Filebrowser to Be Archived. Migrate to a Modern Alternative: Sambee
Filebrowser is being archived. As the author writes, the codebase dates back to when he was but 15 years old. Having created such a popular file management tool is a more than impressive achievement for anyone, let alone a teenager. However, when it comes to security and reliability, Filebrowser seems to be built on a less than ideal foundation, so much so that the author states:
Home Automation, Networking & Self-Hosting