I am executing start command from command prompt.
Command calls batch file named D:\My script.cmd and passes argument "Argument one". Here is command that I am tring to execute.
C:\Users\ABCUser>start "D:\My script.cmd" "Argument one"
but getting error mesasge as The system cannot find the file Argument one.
I don't understand why command is searching for file. Contents of file My script.cmd.
@echo off
cls
echo "Hello"
echo %1
Am I missing something or command syntax is wrong ? This command is not even working for file name without spaces.
It's the well known bug of start/cmd.exe handling a cmd and also an argument with quotes.
The cause is, that start
uses cmd.exe /k to start the new task.
The help of cmd /k and cmd /c explains, that in this case the first and last quote are removed.
And additionally you used the start command wrong.
This should work, as the call works like a dummy to supress the quoting problem
start "Title" call "D:\My script.cmd" "Argument one"
You can use cmd.exe /c "D:\My script.cmd" arg1 arg2
If there is a problem you can switch the /c with /k which will leave the cmd open for you to examin the errors..
gl,
Refael