views:

8724

answers:

6

I need to create a batch file which starts multiple console applications in a Windows .cmd file. This can be done using the start command.

However, the command has a path in it. I also need to pass paramaters which have spaces as well. How to do this?

E.g. batch file

start "c:\path with spaces\app.exe" param1 "param with spaces"
A: 

Your example looks like it should work to me. Did you try it?

Dave Costa
A: 

Surrounding the path and the argument with spaces inside quotes as in your example should do. The command may need to handle the quotes when the parameters are passed to it, but it usually is not a big deal.

Curro
+3  A: 

Escaping the path with apostrophes is correct, but the start command takes a parameter containing the title of the new window. This parameter is detected by the surrounding apostrophes, so your application is not executed.

Try something like this:

start "Dummy Title" "c:\path with spaces\app.exe" param1 "param with spaces"

Steffen
+9  A: 

Actually, his example won't work (although at first I thought that it would, too). Based on the help for the Start command, the first parameter is the name of the newly created Command Prompt window, and the second and third should be the path to the application and its parameters, respectively. If you add another "" before path to the app, it should work (at least it did for me). Use something like this:

start "" "c:\path with spaces\app.exe" param1 "param with spaces"

You can change the first argument to be whatever you want the title of the new command prompt to be. If it's a Windows app that is created, then the command prompt won't be displayed, and the title won't matter.

Andy
Thanks, this helped. I didn't realize the window title was mandatory.
A: 

You are to use something like this:

start /d C:\Windows\System32\calc.exe

start /d "C:\Program Files\Mozilla

Firefox" firefox.exe start /d

"C:\Program Files\Microsoft

Office\Office12" EXCEL.EXE

Also I advice you to use special batch files editor - Dr.Batcher

A: 

Thanks for generously sharing so many useful tips. I am about to begin a blog and this will help me tremendously. Of course it has given me many things to consider as I update my website too. I appreciate it.................

RAJUL