I'm looking to call another CMD instance and pass data to it from the parent instance.
I'm aware of the general route of using variables, but it would not be feasible in this case as endlocal and bridging would be too much of an inconvenience (would have to relay tens of variables). I also know i could use temporary files to port all the data i want easily but this would leave unwanted footprints. EDIT: setx can also be used quite succesfully.
I'm looking specifically for something along the lines of common use of arguments, like:
test.bat -setvar"variable"="value" -setvar...
I did previously find one way with its limitations
Found out on other thread that i can add a command to the end of start cmd
start cmd /c call "test.bat" ^& PAUSE
Of course we can reverse this
start cmd /c call PAUSE ^& TIMEOUT 5 ^& PAUSE ^& test.bat
The commands can't have "" and, i suspect, any special characters. this presents an issue when trying to port complex variables.
Speaking of special characters:
start cmd /c call (PAUSE) ^& (TIMEOUT 5) ^& (REM !"#¤%&/=?`´^*"-.,_:;\*~¨) ^& test.bat
This will not work at all. I might be able to escape interpretation but in the case of some variables i might not have the luxury of knowing enough of the values to be able to process it into anything i could handle. -- Actually it seems parentheses aren't tolerated.
One of the main things i need to do is pass on volume names, which is easily achievable, but this isn't enough.
start cmd /c call echo \\?\Volume{6537febd-01bc-11d6-adb5-806e6f6e6963}\ ^& TIMEOUT 5 ^& PAUSE ^& test.bat
This may already be covered elsewhere and if so the issue is me not finding the right keywords or parallels to the relevant threads.
setx
command which creates a global variable in which you can store your variable so you can read it back from the other routine?setx "name" "variable"
will write to, thus you don't need to run cmd with administrative privileges, unless you specify /M, then it writes to HK_LM and then you need administrative privileges. But for what you want, that is not necessary. To clear a previously assigned variable dosetx "name" ""
Also note that setx variables do not become operational in the current session, only in next sessions. Useset
for the current session.