If you like programming shell scripts for Windows, you might want to run your command prompt scripts in the background silently without actually opening the command prompt windows. This easily possible with a few lines of vbscript.
Why Run It Silently?
A silent prompt is great for scheduled tasks that won’t annoy you with a prompt or even prevent you from running 3D applications such as games. It’s also a great way for administrators to run some tasks in the background or hide activity regular users are not supposed to see. There are a bunch of reasons why they are necessary at times.
Using VBScript To Run CMD Script Silently
Here’s a little snippet of one of my command prompt scripts:
rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:"C:\Windows\Resources\Themes\landscapes.theme"
Let’s say you don’t want Windows 7 to open a command prompt window and run it silently, you can write a vbscript for that:
1. Step Open a notepad editor
2. Step Insert the following code:
Set WshShell = CreateObject("WScript.Shell")
cmds=WshShell.RUN("E:\scripts/themescript.bat", 0, True)
Set WshShell = Nothing
The 0 makes the shell script run silently.
3. Step Save your notepad file. When you save it add the extension .vbs and select All files from the dropdown as seen below:
4. Step You can now schedule that cmd script and it will not open a command prompt window
This is very handy if you don’t want to be annoyed with dozens of command prompt windows when your scheduled tasks are running.
You might also want to know how to open the command prompt in Windows 8