Batch files (.BAT) and Windows NT Command Script (.CMD) files run in console window when double-clicked. This means that the Command Prompt window will be visible until the .BAT/.CMD file execution is complete. To make .BAT or .CMD file execution less intrusive, you can configure it to run minimized. Or if the .BAT or .CMD file does not require user input during run time, you can launch it in invisible mode using a Script. Both options are discussed below.

Running .BAT or .CMD files in minimized mode

1. Create a shortcut to the .BAT or .CMD file. To do so, right click on the file, click Send To, Desktop (create shortcut)

2. Right click on the shortcut and choose Properties

3. In the Run: drop down, choose Minimized

4. Click OK

5. Double-click the shortcut to run the batch file in a minimized window state.

Running .BAT or .CMD files in invisible mode

Windows Script Host’s Run Method allows you run a program or script in invisible mode.

Sample Code

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\Batch Files\syncfiles.bat" & Chr(34), 0
Set WshShell = Nothing

Copy the lines above to Notepad and save the file with .VBS extension. Edit the .BAT file name and path accordingly, and save the file. Double-click the .VBS file to run it.

(Ref: Run Method. Setting intWindowStyle parameter to 0 hides the window)

Bookmark this Page!

BlinkList | del.icio.us | Digg it | Furl | reddit | Spurl | StumbleUpon |

Related Posts


Email SubscriptionPrefer an E-mail subscription?

Enter your email address:

Delivered by FeedBurner

17 Responses to “How to Run .BAT Files Invisibly, Without Displaying the Command Prompt Window” Subscribe to comments!

  1. said this on Saturday, November 7th 2009 3:03 am

    It’s Perfectly Working
    VBS Script is very useful

  2. gus
    said this on Saturday, October 10th 2009 2:27 am

    very useful indeed, but, how can i stop it now? :D

  3. Wut
    said this on Tuesday, August 18th 2009 5:22 pm

    Thank you very much !!

  4. Njay
    said this on Saturday, August 8th 2009 10:02 am

    I don’t know what pane said, but this post really helps. Funny thing at school when notepad pops up every three seconds and theres apparently no reason, ahaha :).
    Thanks for the good work :D.

  5. Mike
    said this on Friday, June 19th 2009 8:44 pm

    Very helpful! I am very much a beginner, and have been trying to figure this out for a while. :-)

  6. Iceman
    said this on Saturday, April 18th 2009 12:07 am

    Thanks, Pane. I was jsut trying to figure that out. Works great for me.

  7. Pane in the Glass
    said this on Sunday, March 1st 2009 3:47 am

    You can use the Arguments property to pass command line parameters:

    WshShell.Run chr(34) & “C:\Batch Files\syncfiles.bat” & Chr(34) & WScript.Arguments(0), 0

    I found it useful to verify the command string before putting it into the script:

    WScript.Echo chr(34) & “C:\Batch Files\syncfiles.bat” & Chr(34) & WScript.Arguments(0)

    Hope that helps!

Leave a Reply