Reputation: 315
I am trying to run a batch file that's located in:
C:\Test Batch\BatchTest.bat
That will copy a file from another specified location, let's say
C:\Users\UserName\Desktop\Company Downloads\downloadedDoc.doc
I can run the batch file as:
cmd /c start "" "C:\Test Batch\TestBatch.bat"
And the batch actually does run.
But when I try to add an argument for it to copy like this:
cmd /c start "" "C:\Test Batch\TestBatch.bat" "C:\Users\User Name\Desktop\Company Downloads\downloadedDoc.doc"
I get:
'C:\Test' is not recognized a an internal or external command, operable program or batch file.
Ultimately the batch file and file to be copied will be specified by a user and will likely have spaces in the names or path. So a simple answer to use paths without spaces will not suffice.
Upvotes: 21
Views: 58137
Reputation: 82400
It's a known feature of cmd.exe
which is started by start.exe
. This happens only when the command has a space in its name or path and at least one of the arguments is quoted.
A workaround is to replace the command with a call
.
start "" CALL "C:\Test Batch\TestBatch.bat" "C:\Users\User Name\down.doc"
Upvotes: 13
Reputation: 2066
Try changing the startup directory with the /d argument to start like so:
cmd /c start "" /d"C:\Test Batch\" "TestBatch.bat" "C:\Users\User Name\Desktop\Company Downloads\downloadedDoc.doc"
The start command has some oddities parsing quotes.
Upvotes: 17