Use the reskit tool pathman.exe:
Pathman accepts four command-line arguments, as follows.
/as path[;path[;path ...]]
Adds paths to the system path.
/au path[;path[;path ...]]
Adds paths to the user path.
/rs path[;path[;path ...]]
Removes the semicolon-separated paths from the system path.
/ru path[;path[;path ...]]
Removes the semicolon-separated paths from the user path.
Technical Notes
Pathman accepts multiple arguments in a single call. Identify each argument with one of the four command-line switches (/as, /au, /rs, and /ru). Each switch can be added in any order as many times as necessary. For each argument, Pathman can accept any number of paths to modify, separated by semicolons.
The /as and /au switches do not add a path that already exists. The /rs and /ru switches do nothing if the path does not currently exist.
Once the path modifications have been made, Pathman broadcasts a message to all top-level windows notifying them that the environment has changed. This causes many applications, including the system shell, to update their environments, thereby obtaining the modified path.
To ensure downward compatibility, Windows NT also loads path information from the Autoexec.bat file in the root directory. However, Pathman does not manage information contained in Autoexec.bat.
Examples
Example 1
pathman /au c:\temp;c:\users\name;d:\utils
In this example, the /au flag tells Pathman to add paths to the current user’s path. All three paths are added to the user’s path if they do not already exist.
Example 2
pathman /au c:\temp;c:\users\name;d:\utils /ru d:\data /as d:\data;c:\reskit
In this example, Pathman adds paths to the current user’s path, removes d:\data from the current user’s path, and adds d:\data and c:\reskit to the system path.
Example 3
pathman /au c:\temp;c:\app\bin /rs %systemroot% /au c:\app2\bin
This command adds c:\temp, c:\app\bin, and c:\app2\bin to the current user's path and removes (%systemroot%) from the system path.
Path Abnormalities
Pathman can handle many path abnormalities. These include:
• Additional leading semicolons
• Additional trailing semicolons
• Multiple consecutive semicolons
• Addition of duplicate paths using /au or /as
• Removal of duplicate paths using /ru or /rs
• Addition and removal of the same path (results in removal)
• Addition of a path that already exists
• Removal of a path that already exists
Pathman does not check the validity of new paths.
Direct download: