开发者

Changing the PATH from a batch

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 ?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜