Take the 2-minute tour ×  How do I write a batch file that backs
up and restores the environment variables.  After that, I want
to set some of the variables and if something goes wrong, I can
rollback the changes with this created batch file.
share|improve this question What operating system are you using?
–  uSlackr Sep 19 '11 at 12:52 it is windows xp –  picknick Sep
19 '11 at 12:53 add comment  3 Answers  Use reg system tool:  To
save system environment:  reg save
"HKLM\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment" env_sys_backup.hiv /y  To save user
environment:  reg save "HKCU\Environment" env_usr_backup.hiv /y
To restore:  reg restore
"HKLM\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment" env_sys_backup.hiv reg restore
"HKCU\Environment" env_usr_backup.hiv  See reg /? for help.
share|improve this answer hmm, that kind of method looks
logical.. I haven't tried it but it looks safe and logical – 
barlop Oct 23 '11 at 0:51 Great solution. But you need to add
the reg key for