This question has been dead for some time now, but because there has not been any suggestion like this, I would like to post it.
My solution (not involving %CMDCMDLINE%
or arguments) is to set any variable before calling another batchfile. It works even with setlocal
or delayed expansion enabled.
parentBatch.bat
@echo off
setlocal
set special=1
call childBatch.bat
childBatch.bat
@echo %special%
Running parentBatch.bat
would print out 1.
I suspect it's related to child processes inheriting environment variables from its parent.