So i have 2 Bat files A and B. A runs, now I use a command to start B. Now A and B are running at the same time. And now I want to send my Variable C from A to B. I tried Call but then it just opens B twice . Thanks for future answeres! Edit* without additional files
32 Answers
The setx command writes a variable into the registry and can be used if you want to use a variable globally for all batch files.
SETX VAR_C somevalueAlternatively you could write the variable to a file and read it back into the other batch file ie;
Batch file A:
SET VAR_C=somevalue
ECHO %VAR_C% >%TMP%\var_cBatch file B:
SET /P VAR_C=<%TMP%\var_c
ECHO %VAR_C% 3 If you were not using the windows command prompt running a and b at the same time is impossible. Even with the call command a is stop and b runs to completion return to a after the call command in true DOS.
When running in windows command prompt they are 2 entirely different processes and don't share memory, variables, or etc.
The way batch files work is they use %1 to %9
shift allows the use of 10 or more values by shifting everything down by 1 and losing the lowest value.
So inside of a.bat call b.bat "scooby doo" "was" "here"
Now inside of b.bat
%1 = "scooby doo"
%2 = "was"
%3 = "here"alternative
The SET command also exists
set C="scooby doo"
echo %c%
From the department of ugly,limited, and hacky
mkdir "\share" mkdir "\share\c" and then in batch file a you could create a file named whatever you want to share.
note: inside a batch file double percent symbols maybe be needed.
for %i in ("c:\x\c\*.*"); do set c="%~ni"However, you can't use the same special characters then, for example the period.
1