Why doesn't the START command work with spaces in arguments and paths?

This command is working

START /b /wait "Dummy title" "C:\tmp\test runner2.bat" arg1 arg2 

But both of them fail!

 START /b /wait "Dummy title" "C:\tmp\test runner2.bat" arg1 arg2 "arg 3" arg4 START /b /wait "Dummy title" "C:\tmp\test runner2.bat" arg1 arg2 "arg 3" 

Mistake:

 'C:\tmp\test' is not recognized as an internal or external command, operable program or batch file. 

Obviously, this has something to do with the " surrounding arguments, but why and how do I do this?

Related questions:

+7
windows command-line-arguments batch-file
source share
3 answers

This is a known START command error.
If you have spaces in both the command and the parameters and try to process them with quotes, it fails.

The START command first checks to see if the full command exists.
But then only the first part begins.

In your case, it searches for "C:\tmp\test runner2.bat" , but try running C:\tmp\test .

You can avoid this when the command is replaced by CALL

 START /b /wait "Dummy title" CALL "C:\tmp\test runner2.bat" arg1 arg2 "arg 3" arg4 

cmd /k used to start a new START process.
And this is the reason for the wrong behavior.
Paul Grocke mentioned the fact that this only happens when it is a batch file.
Exe files will run directly, so they are not affected by the cmd.exe error.

In your case

 C:\Windows\system32\cmd.exe /K "C:\tmp\test runner2.bat" arg1 arg2 "arg 3" arg4 

And the help of cmd /k and cmd /c explains that in this case the first and last quotes are deleted.

+14
source share

Jeb has already pointed in the right direction. In my case, I did not try to run the package, but the program in the "Program Files" folder (the package ends after the program starts). On call

 START "C:\Program Files\MyAppPath\MyApp.exe" arg1 arg2 ... argN 

the path enclosed by quotation marks around should be the "Heading" parameter with the START command. To get rid of this, you should "fake" the window title as follows:

 START "" "C:\Program Files\MyAppPath\MyApp.exe" arg1 arg2 ... argN 

It helped in my case.

+5
source share

This does not answer my question, but it solves the immediate problem that I encountered.

Looking through the issue of quotation marks around file names in the Windows shell "-post, I found a workaround:

 cmd.exe /C ""C:\tmp\test runner2.bat" arg1 arg2 "arg 3" arg4" 

There is another solution by simply executing the command using the call command (as indicated by Ansgar Wiechers )

 call "C:\tmp\test runner2.bat" arg1 arg2 "arg 3" arg4 
+3
source share

All Articles