Aug 15 2009

Windows Batch File Without Popup Console

Sometimes you need to schedule a batch file to run some script periodically on a windows server. I found myself having to run one fairly often and it would always pop up that annoying console window whenever I was in the middle of typing something. This sent me searching for a way to run the script without the pop up console window. There was a few ways to do this but I didn’t want to download and install any other software so I went the vbscript route. Here is what I did.

First create a file and call it ‘somefilename.vbs’ and put it in the same directory as the batch file that you want to run.
Next put this code in it :


Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "my-batch-file.bat", 0, False
Set oShell = Nothing

Now when you set up the windows scheduler you want to point it at the ‘.vbs’ file and not the ‘.bat’ file. That seemed to be the easiest and quickest way to get rid of the console popup when running a batch file on a windows server. If anyone has another method that doesn’t require the creation of a new file I would like to hear it. You could always do some reading on vbscript and just code everything in vbscript and not use a batch file at all but I didn’t bother.

Share