Batch file for environment variables

ravikumarch used Ask the Experts™
Can we write a batch file for updating or creating new environment variables? I am using Vista Business edition.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Batch files (actually cmd which interprets batches) obtain copy of environment. They can modify own copy but this has no system-wide impact.
If you run any app from this batch file - this app inherits modified environment from cmd. If you close cmd - your environment changes are lost. Only method of modyfing system wide variables relies on registry modification. You can do it via reg.exe and modify hive HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment.
Remember that running processes have their own copies of environment so they are not affected until process restart.
In Windows Vista a new command was first introduced:


It gives you the ability to modify the environment  in user or system space. It is quite powerfull.
Remeber that you micht need an elevated command prompt for this to work.


Thanks..this really helped..i was ignorant about this for a long time..thanks again..

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial