In my puppet script, I have 2 calls to exec that execute different batch files
exec {
command => 'file1.bat'
}
exec {
command => 'file2.bat'
}
If file1.bat sets an environment variable using SET
SET VAR1=someVal
it is not accessible from file2.bat, which I expected.
However, if I use SETX
SETX VAR1 someVal -m
it is still not available in file2.bat.
The only way I have been able to make the variable changes available to file2.bat is by setting the variable directly in the registry (using reg ADD) in file1.bat and then querying it (using reg QUERY) in file2.bat. Is there a better way to do this?
I cannot combine file1.bat and file2.bat into a single script because they are used independently elsewhere.