Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows start command not able to execute batch file

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.

like image 329
sagar Avatar asked Mar 04 '26 12:03

sagar


1 Answers

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"
like image 123
jeb Avatar answered Mar 06 '26 00:03

jeb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!