Skip to content


How to hide a program running in the command line

There can be various reasons for hiding a running command line program: doing some silent maintenance without annoying the casual user, or without risking an accidental closure, running a program in the background – saving space in the taskbar – without the need to install it as a service, etc. However, there’s no trivial “point’n click” way to do so. It is however quite easy to achieve trough a couple of visual basic script (VBS) lines.

Basically, first you create a script shell, then you use it to run your program, and choose to make it non-visible. Here is a first example I found on the techArena forums:
Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run "cmd /K CD C:\ & Dir>test.txt", 0, false

(NB for the clueless: create this with a plain text editor and then save with a .vbs extension)

Note that editing this file can be a bit tricky and error-prone, so my suggestion would be to create such a VBS to launch a specific batch (.bat) file, and then to make adjustments (such command line parameters) only in the batch file. That would make a VBS such as:
Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run "cmd /K CD C:\Path\to\the\batch\ & batchFile.bat", 0, false

and then put whatever you want in batchFile.bat (again, created with any plain-text editor), such as:
C:\My\Cool\Hidden\program.exe -option1 someValue

That’s pretty much it. Sorry the VBS is a bit obscur to me so I can’t really explain it in details, however this just works great. The only little problem is that the only way I found to stop the background task is via the task manager.

Finally, one other source that could be interesting: How Can I Hide the Command Window When Executing a Command Like net Localgroup Administrators?

Posted in programming, Windows.


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Khayo says

    thank you! worked perfectly!



Some HTML is OK

or, reply to this post via trackback.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA