use batch file to set global variables (1 Viewer)

Guus2005

AWF VIP
Local time
Today, 01:55
Joined
Jun 26, 2007
Messages
2,645
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?
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:55
Joined
Sep 21, 2011
Messages
14,231
Set it as an environment variable, or pass it on to next script.
 

Guus2005

AWF VIP
Local time
Today, 01:55
Joined
Jun 26, 2007
Messages
2,645
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?
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:55
Joined
Sep 21, 2011
Messages
14,231
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

Top Bottom