PATHMAN.EXE: PathMan

Windows NT® Resource Kits

Copyright © Microsoft Corp. 1995 - 1997

Contents

What is PathMan?

What does PathMan do?

Pathman syntax

Pathman examples

Path abnormalities

Return value

What does PathMan do?

This command-line tool enables you to add or remove components of both the system and user paths. It can modify any number of paths in a single call and includes error checking that can handle path abnormalities such as repeated entries, adjacent semicolons, and missing entries.

Windows NT manages two different types of paths; the current user's path and the system path. Windows NT keeps a separate user path for every user on a system, but there is only one global system path. When a user logs on to a Windows NT machine, these two paths are combined to create the user's full path. For backward compatibility, Windows NT also loads path information from old AUTOEXEC.BAT files left in the root directory.

A non-administrative user can modify his or her own user path. But in order to modify the system path, the user of pathman must have Administrator privileges. Pathman does not manage information contained in old AUTOEXEC.BAT files.

Pathman also broadcasts a message to all top-level windows notifying them that the environment has changed. This causes many applications (like the system shell) to update their environments, thereby obtaining the modified path.

PathMan syntax

Pathman accepts four command line arguments:

/as path[;path[;path ...]]

Adds the semicolon-separated paths to the system path

/au path[;path[;path ...]]

Adds the semicolon-separated 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

The two add flags, /as and /au, will not add a path that already exists. The two remove flags, /rs and /ru, will do nothing if the path does not currently exist.

Pathman can accept multiple arguments in a single call, each identified by one of the four command line flags (/as, /au, /rs, /ru). Each flag can be added in any order as many times as desired. For each argument, Pathman can accept any number of paths to modify (represented above by path). Each path must be separated by a semicolon.

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.

Pathman examples

Example 1

pathman /au c:\temp;c:\users\name;d:\utils

In this example, the /au flag tells Pathman that the next set of semicolon separated paths should be added to the current user's path. All three paths (c:\temp, c:\users\name, and d:\utils) will be 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

Aside from the additions to the current user's path, d:\data is removed form the current user's path and both d:\data and c:\reskit are added to the system path. Pathman can accept any number of path modifications this way.

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 user path and removes (%systemroot%) from the system path.

Path abnormalities

Pathman can handle many path abnormalities. These include:

Return value

Pathman's return value is complicated, because the utility needs to return a lot of information in a single 32-bit value. In order to return status information for each of the four possible flags (/as /au /rs /ru) it accepts as arguments, Pathman treats the return value as four separate 8-bit bytes instead of one 32-bit integer. Each of the four bytes in the return value indicates what action was taken with respect to each of the four flags accepted by Pathman. The return value (wwxxyyzz) is broken down as follows:

byte

4 3 2 1

ww xx yy zz

byte 4 (ww)system path additions

byte 3(xx)user path additions

byte 2 (yy)system path removals

byte 1 (zz)user path removals

Each byte in the return code can have a value of:

0No changes were made.

1At least one change was made.

2An error occurred. No changes were made.

In Example 1:

pathman /au c:\temp;c:\users\name;d:\utils

if we assume that there were no errors and at least one of the paths was added to the user's path, we get a return value of (in hex followed by decimal in parentheses) :

0x00010000(65536)

In Example 2:

pathman /au c:\temp;c:\users\name;d:\utils /ru d:\data /as d:\data;c:\reskit

if we again assume that everything worked, we get a return value of:

0x01010001( 16842753)

If the user did not have Administrator privileges, the return value would have been:

0x02010001( 33619969)

If Pathman is called with invalid parameters, the return value is all errors:

0x02020202(33686018)