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
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 somevalue
Alternatively 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_c
Batch file B:
SET /P VAR_C=<%TMP%\var_c ECHO %VAR_C%
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"
The SET command also exists
set C="scooby doo"
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.