Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting DOS Environment Variables

Status
Not open for further replies.

mbzung

Programmer
Aug 27, 2002
1
US
I'm trying to run a .bat file that sets environment variables. Here's how my TCL looks:

# Set env variables #
exec test.bat
# DOS command to print value of variable (does not contain new value) #
puts [exec cmd.exe /c echo %ENVVARIABLE%]

The .bat is executed and the variables are set when I echo from the .bat, but when control returns to my TCL script, they are no longer there. Please help...

Thanks.
 
When a programm call another program, the environment of the parent is copied to the environment of the child.
The child can't see, nor modify the parent environment.

What you can do is to modify the Tcl environment through the ::env array.
Modifying this array, you modify your program environment so all children (exec'ed progs) will see the updates.

bat file:
@set newvar

Tcl script:
set env(newvar) "some value"
puts [exec seevar]
->newenv=some value

Good luck!

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top