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!

Permanently setting Environment Variables in DOS

Status
Not open for further replies.

Imagineer

New member
Mar 28, 2000
43
US
I'm trying to set some environment variables in a DOS (actually WinNT 4.0 cmd) shell. I know that changing the value in the ENVIRON variable does not pass the value back to the shell. I've tried using the system() command thusly,

sVar = "EnvTest"
sValue = "oldhat"
if (system("Set " sVar "=" sValue )!= 0) #Set var and check for error.

and

if (system("Set EnvTest=oldhat")!=0) #Set var and check for error.

Neither statement returns an error nor do they set the variable.

Any ideas?
TIA,
Mark Imagineer
 
I hope I understand you correctly.

can't you set these vars in:
start
controlpanel
system
advanced
environment variables.

Then it is permanent.

regards
Gregor.Weertman@mailcity.com
 
Permanence is a relative thing. What I meant was that I needed them to last beyond the current session of awk. Awk allows you to read the environment variables using the ENVIRON array. The values in the ENVIRON array can be changed but they do not return these values back to the OS. All changes are lost when Awk ends. I am using the environment variables to pass values from one program to another. Imagineer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top