Computing.Net > Forums > Disk Operating System > Copying Enviroment Variables?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Copying Enviroment Variables?

Reply to Message Icon

Name: Randy
Date: May 5, 2003 at 07:02:25 Pacific
OS: Windows 98 SE
CPU/Ram: Athlon 1.1 Ghz /128mb SDR
Comment:

Is there any way to copy an enviroment variable in a batch file, copy it, call another batch file, then paste it to the called batch file?
thx in advance



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: May 5, 2003 at 15:13:34 Pacific
Reply:

Your question makes no sense at all to me. Please explain it better. That do you mean by copy/paste an environment variable?

If you're simply asking how to use on a batch file a variable which was set from an another batch file, it's simple - the variables preserve their state when the batch file ends, unless it is been run on a child shell and it ends with the batch file, like this:

%comspec% /c batchfile.bat

Otherwise, the variables will remain, so all you have to do is use them on the other batch file.

You can also call the second batch file with the variable as a parameter, like this:

another.bat %MyVar%

Then, on another.bat, %1 would represent the value of %MyVar% (there will be some trouble if the variable contains spaces, tabs, ';'s or ','s).

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Copying Enviroment Variables?

Setting CD to a Variable www.computing.net/answers/dos/setting-cd-to-a-variable/12013.html

CD-Rom variable and Win 98 startup www.computing.net/answers/dos/cdrom-variable-and-win-98-startup/12125.html

DOS environment variables, Help!! www.computing.net/answers/dos/dos-environment-variables-help/11340.html