This is much simpler implementation of my actual batch files, but they serve purpose of illustrating my issue...
I have one batch file, b.cmd which simply echos the input argument:
REM - *** B.CMD
@echo off
echo %1
echo %~1
I have another batch file a.cmd which starts b.cmd:
REM - *** A.CMD
@echo off
set Location=C:\Users\yogi\AppData\Local\Temp\test
REM - This location could contain spaces, hence on the next line
REM - I am surrounding %Location%\b.cmd with QUOTEs.
start "" "%Location%\b.cmd" "Input Argument 1"
If I execute a.cmd, I get error:
'C:\Users\yogi\AppData\Local\Temp\test\b.cmd" "Input' is not recognized as an internal or external command,
operable program or batch file.
However, if I remove QUOTEs around the %Location%\b.cmd from a.cmd, I get this (as I expected):
"Input Argument 1"
Input Argument 1
What am I doing wrong? I need QUOTEs around %Location%\b.cmd as well as input argument because both these could contain spaces.
Edited
Here is the output from a.cmd. Echo is on and b.cmd is called WITHOUT QUOTEs around it:
C:\Users\yogi\AppData\Local\Temp\test>a.cmd
C:\Users\yogi\AppData\Local\Temp\test>set Location=C:\Users\yogi\AppData\Local\Temp\test
C:\Users\yogi\AppData\Local\Temp\test>start "" C:\Users\yogi\AppData\Local\Temp\test\b.cmd "Input Argument 1"
C:\Users\yogi\AppData\Local\Temp\test>
Here is the output from b.cmd:
C:\Users\yogi\AppData\Local\Temp\test>echo "Input Argument 1"
"Input Argument 1"
C:\Users\yogi\AppData\Local\Temp\test>echo Input Argument 1
Input Argument 1
C:\Users\yogi\AppData\Local\Temp\test>
Here is the output from a.cmd. Echo is on and b.cmd IS called WITH QUOTEs around it:
C:\Users\yogi\AppData\Local\Temp\test>a.cmd
C:\Users\yogi\AppData\Local\Temp\test>set Location=C:\Users\yogi\AppData\Local\Temp\test
C:\Users\yogi\AppData\Local\Temp\test>start "" "C:\Users\yogi\AppData\Local\Temp\test\b.cmd" "Input Argument 1"
C:\Users\yogi\AppData\Local\Temp\test>
Here is the output from b.cmd:
'C:\Users\yogi\AppData\Local\Temp\test\b.cmd" "Input' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\yogi\AppData\Local\Temp\test>