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)

Related Posts


Email SubscriptionPrefer an E-mail subscription?

Enter your email address:

Delivered by FeedBurner

26 Comments

  1. said this on Sunday, August 29th 2010 5:40 am

    Thank you! Worked great, I was using a .cmd script to run every 5 minutes and it was rather annoying that the command prompt window would pop up every 5 minutes to run it. The VBS you gave made it run completely invisible now. Thanks again.

  2. ankit
    said this on Friday, August 27th 2010 9:03 pm

    Good job dude!!

  3. Rajat
    said this on Friday, July 30th 2010 9:31 pm

    fantastic. thanks man.

  4. Thiago
    said this on Friday, July 30th 2010 7:27 am

    Brilliant! Thanks a lot

  5. said this on Friday, June 25th 2010 7:56 pm

    This worked perfectly for me. Thanks for the script!

  6. Harsha
    said this on Monday, June 14th 2010 6:36 pm

    helped a lot. thank you very much.
    its working good.

Leave a Reply