Posted By: Tammen
How can I run a CMD or .bat file in silent mode? I’m looking to prevent the CMD interface from being shown to the user.
I have proposed in StackOverflow question a way to run a batch file in the background (no DOS windows displayed)
That should answer your question.
Here it is:
From your first script, call your second script with the following line:
wscript.exe invis.vbs run.bat %*
Actually, you are calling a vbs script with:
- the [path]name of your script
- all the other arguments needed by your script (
Then, invis.vbs will call your script with the Windows Script Host Run() method, which takes:
- intWindowStyle : 0 means “invisible windows”
- bWaitOnReturn : false means your first script does not need to wait for your second script to finish
See the question for the full invis.vbs script:
Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run """" & WScript.Arguments(0) & """" & sargs, 0, False ^ means "invisible window" ---|
Update after Tammen’s feedback:
If you are in a DOS session and you want to launch another script “in the background”, a simple
/b (as detailed in the same aforementioned question) can be enough:
You can use
start /b second.batto launch a second batch file asynchronously from your first that shares your first one’s window.