tags:

views:

17

answers:

1

I'm writing a dos-batch in which I need to change the PATH.

I'm using the SET command.

The batch is run from the command line (cmd.exe).

The problem : the changes are only available for the cmd window, and I soon as this window is closed, the changes are dismissed.

How can I change the PATH from a batch and make sure the change will affect the whole system ?

+3  A: 

There is a tool setx.exe provided in the Windows XP Service Pack 2 Support Tools that can be used to permanently change an environment variable from the command line:

setx path "%PATH%;C:\New Folder"

Source: http://vlaurie.com/computers2/Articles/environment.htm

The above link also gives the location of the registry keys that store the system / user environment variables - if you are feeling adventurous you could also try setting those.

User environment variables:

HKEY_CURRENT_USER\Environment

System environment variables:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Kragen