use batch file to set global variables

Guus2005

AWF VIP
Local time
Today, 08:03
Joined
Jun 26, 2007
Messages
2,642
How can i use a batch file to set a variable so that it doesn't vanish after the script is done?

Code:
rem File1.bat
set variable1=foo

Code:
rem File2.bat
echo %variable1%

When i run File2 after File1 variable1 is not recognised.

So the scope of variable1 is only within File1.bat present.
How can i change that?
 
Set it as an environment variable, or pass it on to next script.
 
The scope of variables in a batch file is restricted to that batch file.
@Gasman "Set it as an environment variable" how do i do that?
 
The scope of variables in a batch file is restricted to that batch file.
@Gasman "Set it as an environment variable" how do i do that?
Yes. But nothing to stop you passing it on to the next batch file?
Use shell to execute the set command.
 

Users who are viewing this thread

Back
Top Bottom