0

I have created a batch(batA) file that kicks off another batch(marathon.bat) file. When I save batA onto my desktop and use

start /wait ..\marathon\marathon.bat -batch "C:\stuff"

it works just fine. However, when I save marathon.bat to my program files, which now has spaces in the name, and then use

start /wait c:\"Program Files (x86)\marathon\marathon.bat" -batch "c:\stuff"

I get the error:

'c:\Program' is not recognized as an internal or external command, operable program or batch file.

I know that you have to use double quotes so that it takes the spaces into consideration, but why is it stopping at c:\Program? I've tried moving the quotes around to different locations, but I can't seem to get it to recognize the second file.

Ross Allen
  • 43,772
  • 14
  • 97
  • 95
Nick L
  • 281
  • 1
  • 6
  • 18

2 Answers2

0

You have 2 problems with how you call your batch file.

First, you have placed your quotes at the wrong place. Instead of

start /wait c:\"Program Files (x86)\marathon\marathon.bat" 

You should enclose your whole command with quotes, not only from the Program Files folder name:

start /wait "c:\Program Files (x86)\marathon\marathon.bat" 

The second problem is that the first parameter with quotes specified to the START command is treated as the title of the new window. You should add an empty set of quotes before your command to circumvent this:

start "" /wait "c:\Program Files (x86)\marathon\marathon.bat" 
Laf
  • 7,965
  • 4
  • 37
  • 52
  • I put the double quotes there because earlier in the batch file that is the way that i have to kick off a vbscript. 'c:\"rest of file path"' works while '"c:\rest of file path"' does not work. Also, adding the two sets of double quotes after the start command doesn't make any difference for me. I still get the same error. – Nick L Jan 30 '14 at 14:48
  • @NickL Have you tried the part with the empty quotes? Does this fix your problem? – Laf Jan 30 '14 at 14:50
  • When you say empty quotes I assume you mean just after the start command (start ""). Yes, I have tried that and it doesn't work. I didn't know if you meant "" or " " (first one with no space between and second one with a space). I have tried both and neither of them work. – Nick L Jan 30 '14 at 14:53
  • Are said start instructions within a loop of some sort? Do you close every quotation mark before? What does the interpreter say when you mean it does not work? (attempting the empty double quote solution) – MrPaulch Jan 30 '14 at 14:58
  • @MrPaulch No loop. It is a very simple file. It kicks off a vbscript, If errorlevel == 0 then goto starttests which is where I'm running into this problem. I receive the same error when attempting the empty double quote solution. – Nick L Jan 30 '14 at 15:03
  • Can you verify that the error comes fromt executing the start command or does it already trigger at the section where you execute the VB Script? – MrPaulch Jan 30 '14 at 15:05
0

Does this work for you?

 start "" /wait %comspec% /c "c:\Program Files (x86)\marathon\marathon.bat" -batch "c:\stuff"
Nick L
  • 281
  • 1
  • 6
  • 18
foxidrive
  • 40,353
  • 10
  • 53
  • 68