How to run .BAT files invisibly, without displaying the Command Prompt window

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 Using Script

Windows Script Host’s Run Method allows you run a program or script in invisible mode. Here is a sample Vbscript code that launches a .BAT file named syncfiles.bat.

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

Copy the above lines 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)

About the author

Ramesh Srinivasan founded back in 2005. He is passionate about Microsoft technologies and has a vast experience in the ITeS industry — delivering support for Microsoft's consumer products. He has been a Microsoft MVP [2003 to 2012] who contributes to various Windows support forums.

39 thoughts on “How to run .BAT files invisibly, without displaying the Command Prompt window

  1. Awesome application!!! Would love the ability to copy and paste the GUID rather than have t export the .XML, rename that file and then do it again. Even better would be a data dump to a notepad or excel for rapid reference of the GUID.

  2. Useless explanation. What does “Copy the lines above to Notepad and save the file with .VBS extension.” mean???????

    What lines? I have a simple .bat file that I want to run “hidden”. This explanation looks really encouraging till I find an unexplainable statement like that.

    OK – I guess I’m just stupid.

  3. Marvellous! It is really helped us in WebLogic server to run in the background. it is almost equalent to Unix & and nohup.

  4. Marvellous, I used to run java jar files without showing comand screen.
    Thank you so much.

  5. Thanks for this, but I’m calling the bat file from an XML file that also includes parameters to be passed to it.
    How can I pass parameters to the bat file is I’m calling the VBS file instead?

  6. This is fantastic! Thank you very much!

    Next, to figure out how to pass the location and name of the .bat to be run, into the vbs script…then I could have 1 invisible.vbs script that executes the desired .bat file.

  7. This isn’t working for me on Windows server 2008… the Command Window is still opening.

    Any ideas?!

  8. SWEET! Just what i was trying to do. I have batch jobs that run every minute and it’s annoying to have them pop up all the freakin time. Thanks so much!

  9. The minimizing the execution of the shortcut does not work in Windows 7 — shortcuts for .BAT files are not editable in the way described.

    The VBS approach works just fine, however.

    Thanks for that neat way of running a repetitive script inthe background.

  10. 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.

  11. 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!

  12. AutoHotkey can run things hidden too…
    Run, somebat.bat, , Hide
    Run, %1%, , Hide

    …put the 2nd example in RunHidden.ahk…then add a Run Hidden option to the .bat right-click menu…

    Windows Registry Editor Version 5.00

    @=”Run &Hidden”

    @=”\”C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\” \”C:\\Program Files\\AutoHotkey\\RunHidden.ahk\” \”%1\” %*”

    …I didn’t test that, but I hope you get the idea anyway…also I don’t know if this blog supports…
    …tags…so I didn’t use them…& no preview…

Comments are closed.