How to create batch file in Windows using "start" with a path and command with spaces

WindowsBatch FileScripting

Windows Problem Overview


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"

Windows Solutions


Solution 1 - Windows

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.

Solution 2 - Windows

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"

Solution 3 - Windows

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

When I used above suggestion, I've got:

> 'c:\path' is not recognized a an internal or external command, operable program or batch file.

I think second qoutation mark prevent command to run. After some search below solution save my day:

start "" CALL "c:\path with spaces\app.exe" "C:\path parameter\param.exe"

Solution 4 - Windows

Interestingly, it seems that in Windows Embedded Compact 7, you cannot specify a title string. The first parameter has to be the command or program.

Solution 5 - Windows

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

Solution 6 - Windows

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.

Solution 7 - Windows

I researched successfully and it is working fine for me. My requirement is to sent an email using vbscript which needs to be call from a batch file in windows. Here is the exact command I am using with no errors.

START C:\Windows\System32\cscript.exe "C:\Documents and Settings\akapoor\Desktop\Mail.vbs"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTimView Question on Stackoverflow
Solution 1 - WindowsAndyView Answer on Stackoverflow
Solution 2 - WindowsSteffenView Answer on Stackoverflow
Solution 3 - WindowsMustafa KemalView Answer on Stackoverflow
Solution 4 - WindowsMark AgateView Answer on Stackoverflow
Solution 5 - Windowsuser243871View Answer on Stackoverflow
Solution 6 - WindowsCurroView Answer on Stackoverflow
Solution 7 - WindowsAnupam KapoorView Answer on Stackoverflow