79

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"

7 Answers7

168

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
  • 30,088
  • 6
  • 78
  • 89
  • It seems the window title is mandatory though there is lots of documentation on the internet stating otherwise. Ignore that documentation. Follow Andy's suggestion. – Corin Aug 22 '11 at 19:22
  • If I enter a windows application command from an interactive, the application launches in the background and I see a new prompt. If I run the same command from a batch script, application launches in the foreground; my batch script stops until I exit the app. Eek! I tried for a long time to use start to run my app in the background, but `start /B "app"` wouldn't work, and `start cmd /C "app"` gives me an extraneous console. Thank you!! I finally learnd I need a window title for my non-window start. This works: `start /B "" "app"` – Keith Robertson Jan 17 '13 at 14:25
  • Thanks! The case is actual even with `/wait` parameter specified! `start /wait "%CDir%\cron.exe" -q -remove` doesn't work while `start "" /wait "%CDir%\cron.exe" -q -remove` does. – Fr0sT Jan 16 '15 at 13:56
16

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"
slavoo
  • 5,798
  • 64
  • 37
  • 39
Steffen
  • 2,888
  • 19
  • 19
2
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"
player0
  • 124,011
  • 12
  • 67
  • 124
Mustafa Kemal
  • 1,292
  • 19
  • 24
  • Create an empty file `test 2.bat`, then create a file `test1.bat` with this: `START "Test title" "test 2.bat" %*` - now run `test1.bat "param 1"` and it won't work, why? – ale5000 Aug 26 '20 at 23:14
1

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.

Mark Agate
  • 11
  • 1
0

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

Community
  • 1
  • 1
-1

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"
kleopatra
  • 51,061
  • 28
  • 99
  • 211
  • This is wrong. You can write `START "" "C:\Documents and Settings\akapoor\Desktop\Mail.vbs"`. Your code is only working because vbs is an extension which is resolved when you "start" it. Try calling notepad.exe with the path, it won't work. It will always execute the script. – Samuel Mar 24 '15 at 14:28
-1

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
  • 832
  • 2
  • 10
  • 14