"batch files" "silent mode" "@echo off"

notcjw used Ask the Experts™
I am trying to suppress the dos window that appears when a batch file runs. I take care of about 50 public workstations and I want a batch file to run when the user logs in but I don't want them to be able to see it. What has been happening is the batch file starts but the user closes it before the batch finishes and so the task is not completed. I've tried @echo off but this doesn't seem to do anything.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
@echo off will just prevent the batch file from outputting the lines it is executing to the console. The window will still show no matter what because the batch file has to run from within a command window.

Try starting it using the START statement, passing it the /MIN parameter so that it starts minimized. At least that way it doesn't appear right in the user's face.
start /min %comspec% /c yourbatchfile.bat

Open in new window

I found this..

To have an MS-DOS Batch file run in a hidden window:

In these circumstances, there is no MS-DOS window, nor any
corresponding Taskbar button, so the Batch Code should begin
@ECHO OFF and end with CLS and/or EXIT, or the process may
stall invisibly.

For example, if the Batch file to be run in a hidden window
is named C:\WORK\MYBATCH.BAT, create the following .VBS file:

====Begin cut-and-paste (omit this line)
CreateObject("Wscript.Shell").Run "C:\WORK\MYBATCH.BAT",0

====End cut-and-paste (omit this line)

Requires Windows Script Host installed. Double-click or otherwise
execute the .VBS file, for example, with the START command:

start MyFile.VBS

to run the Batch file invisibly.

Try this:


or another way:

The coolest way is to make the batch file run totally
invisibly. This is just a little dangerous because your
batch file MUST be able to close itself and MUST never
produce an error which might require user input.
Otherwise the batch file will hang invisibly until
system shutdown or until someone kills it with the task
manager. To do this trick REQUIRES that you have Windows
Scripting installed. Scripting is standard on Win98 and
newer, and is an optional free download for Win95. To
test, type "wscript" in the Start/Run dialog. If you get
a settings dialog, you have it. If you get an error or
Windows offers to find it for you, you don't have it.
See my scripting web page for more info:
Save this one line of text as "invisible.vbs":
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
To run any program or batch file invisibly, use it like this:
wscript.exe "C:\Wherever\invisible.vbs" "C:\Some Other Place\MyBatchFile.bat"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial