Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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

![]() |
![]() |
![]() |

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