salt.modules.win_path

Manage the Windows System PATH

Note that not all Windows applications will rehash the PATH environment variable, Only the ones that listen to the WM_SETTINGCHANGE message.

salt.modules.win_path.add(path, index=None, **kwargs)

Add the directory to the SYSTEM path in the index location.

Parameters:
  • path (str) -- Directory to add to path

  • index (int, optional) --

    Optionally specify an index at which to insert the directory

    Default is None.

Kwargs:

rehash (bool, optional):

If the registry was updated, and this value is set to True, sends a WM_SETTINGCHANGE broadcast to refresh the environment variables. Set this to False to skip this broadcast.

Returns:

True if path was added, otherwise False.

Return type:

bool

CLI Examples:

# Will add to the beginning of the path
salt '*' win_path.add 'c:\python27' 0

# Will add to the end of the path
salt '*' win_path.add 'c:\python27' index='-1'
salt.modules.win_path.exists(path)

Check if the directory is configured in the SYSTEM path Case-insensitive and ignores trailing backslash

Parameters:

path (str) -- Path to the directory to check

Returns:

True if path exists, otherwise False.

Return type:

bool

CLI Example:

salt '*' win_path.exists 'c:\python27'
salt '*' win_path.exists 'c:\python27\'
salt '*' win_path.exists 'C:\pyThon27'
salt.modules.win_path.get_path()

Returns a list of items in the SYSTEM path

CLI Example:

salt '*' win_path.get_path
salt.modules.win_path.rehash()

Send a WM_SETTINGCHANGE Broadcast to Windows to refresh the Environment variables for new processes.

Note

This will only affect new processes that aren't launched by services. To apply changes to the path to services, the host must be restarted. The salt-minion, if running as a service, will not see changes to the environment until the system is restarted. See MSDN Documentation

CLI Example:

salt '*' win_path.rehash
salt.modules.win_path.remove(path, **kwargs)

Remove the directory from the SYSTEM path

Parameters:

path (str) -- Directory to remove from path

Kwargs:

rehashTrue

If the registry was updated, and this value is set to True, sends a WM_SETTINGCHANGE broadcast to refresh the environment variables. Set this to False to skip this broadcast.

Returns:

True if successful, otherwise False.

Return type:

bool

CLI Example:

# Will remove C:\Python27 from the path
salt '*' win_path.remove 'c:\\python27'