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

PowerShell Script: Test Chrome, Firefox & IE Browser Performance

PowerShell Script: Test Chrome, Firefox & IE Browser Performance
There is more than one way to test the performance of web browsers like Chrome, Firefox, or IE, but regardless of how you do it, you need a consistent workload that makes the browsers comparable. Unless you are testing with synthetic benchmarks (which come with a plethora of problems of their own) you need a way to automate browsers opening tabs and loading URLs. This article presents a simple solution to do just that.
Scripting

Latest Posts

Scripted WordPress to Hugo Migration

Scripted WordPress to Hugo Migration
After having published in WordPress for almost 20 years, it was time for a change. This site is now rendered by Hugo, a static website generator built for Markdown content hosted in a Git repository. The migration from WordPress (HTML) to Hugo (Markdown) was far from trivial. Since I couldn’t find any tool for the job, I developed my own set of migration scripts that fully automate the migration process. You can find them on GitHub along with extensive documentation.
Website