On WinXP, can I run a batch (.bat or .cmd) file, via a shortcut, without a "black window" ?

link|improve this question

40% accept rate
2  
Are you asking if you can prevent the command window from showing up when you run a bat file? – Eric U. May 11 '10 at 17:36
feedback

migrated from stackoverflow.com May 11 '10 at 18:32

This question came from our site for professional and enthusiast programmers.

5 Answers

Save the following as wscript, for instance, hidecmd.vbs after replacing "testing.bat" with your batch file's name.

Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd /c testing.bat"
oShell.Run strArgs, 0, false

The reference is here http://msdn.microsoft.com/en-us/library/d5fk67ky.aspx

link|improve this answer
feedback

Use start with the '/B' option. For example:

@echo off
start /B go.bat
link|improve this answer
4  
start /b will just run the program in the currently-allocated console instead of spawning a new one. You'll get a new one anyway since the batch has to run with cmd (which, in turn [surprise], opens a console). – Joey May 11 '10 at 18:02
feedback

You can change the properties of the of the shortcut to run minimized.

To run it completely invisibly you'll need something else like Windows Scripting.

link|improve this answer
Your first suggestion is the way I've always done it. – martineau Mar 19 at 23:32
feedback

This is just a simplification of Shaji's answer. You can run your batch script through a vbs script like this:

'HideBat.vbs
CreateObject("Wscript.Shell").Run "your_batch_file.bat", 0, True

This will execute your batch file with no cmd window shown.

link|improve this answer
feedback

Use Hidden Start

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.