Manager (Lispusers) grow anchor, icon, and fix typo. (#1346)
* File See operations use full path to loaded file.
Add Manager.WINDOW-ANCHOR to fix corner from which MANAGER-MAIN-WINDOW grows, and (attempt) to keep it on-screen.
* Improved handling of the ICONW for MANAGER-MAIN-WINDOW.
* Fix typo in MasterScope functions (multiple occurrences: LOADBFLG should be LOADDBFLG).
Changed to CL compiler by default (not need to go to submenu). This is my preference, so I should remove it before setting pull request.
* Manual cleanup of multiple "Edited" comments in 4 FNS.
Reverted: Changed to CL compiler by default (not need to go to submenu). (From commit f60c6362)
* Update MANAGER.TEDIT documentation file.
Fix error in previous commit. (Changes that I thought were there, were not.)
Cleanup COMMON-MAKE COMS so it can be handled by the file package, and add .LCOM file to the repo.
This commit is contained in:
@@ -1,165 +1,165 @@
|
||||
; Copyright (C) 2021-2023 by Bill Stewart (bstewart at iname.com)
|
||||
;
|
||||
; This program is free software; you can redistribute it and/or modify it under
|
||||
; the terms of the GNU Lesser General Public License as published by the Free
|
||||
; Software Foundation; either version 3 of the License, or (at your option) any
|
||||
; later version.
|
||||
;
|
||||
; This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
; FOR A PARTICULAR PURPOSE. See the GNU General Lesser Public License for more
|
||||
; details.
|
||||
;
|
||||
; You should have received a copy of the GNU Lesser General Public License
|
||||
; along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
; Sample Inno Setup (https://www.jrsoftware.org/isinfo.php) script
|
||||
; demonstrating use of PathMgr.dll.
|
||||
;
|
||||
; This script uses PathMgr.dll in the following ways:
|
||||
; * Copies PathMgr.dll to the target machine (required for uninstall)
|
||||
; * Defines a task in [Tasks] that should modify the Path
|
||||
; * Imports the AddDirToPath() DLL function at setup time
|
||||
; * Imports the RemoveDirFromPath() DLL function at uninstall time
|
||||
; * Stores task state as custom setting using RegisterPreviousData()
|
||||
; * Retrieves task state custom setting during setup and uninstall initialize
|
||||
; * At post install, adds app dir to Path if task selected
|
||||
; * At uninstall, removes dir from Path if custom setting present
|
||||
; * Unloads and deletes DLL and removes app dir at uninstall deinitialize
|
||||
|
||||
#if Ver < EncodeVer(6,0,0,0)
|
||||
#error This script requires Inno Setup 6 or later
|
||||
#endif
|
||||
|
||||
[Setup]
|
||||
AppId={{A17D2D05-C729-4F2A-9CC7-E04906C5A842}
|
||||
AppName=EditPath
|
||||
AppVersion=4.0.4.0
|
||||
UsePreviousAppDir=false
|
||||
DefaultDirName={autopf}\EditPath
|
||||
Uninstallable=true
|
||||
OutputDir=.
|
||||
OutputBaseFilename=EditPath_Setup
|
||||
ArchitecturesInstallIn64BitMode=x64
|
||||
PrivilegesRequired=none
|
||||
PrivilegesRequiredOverridesAllowed=dialog
|
||||
|
||||
[Files]
|
||||
; Install PathMgr.dll for use with both setup and uninstall; use
|
||||
; uninsneveruninstall flag because DeinitializeSetup() will delete after
|
||||
; unloading the DLL; install the 32-bit version of PathMgr.dll because both
|
||||
; setup and uninstall executables are 32-bit
|
||||
Source: "i386\PathMgr.dll"; DestDir: "{app}"; Flags: uninsneveruninstall
|
||||
|
||||
; Other files to install on target system
|
||||
Source: "i386\EditPath.exe"; DestDir: "{app}"; Check: not Is64BitInstallMode()
|
||||
Source: "x86_64\EditPath.exe"; DestDir: "{app}"; Check: Is64BitInstallMode()
|
||||
Source: "EditPath.md"; DestDir: "{app}"
|
||||
|
||||
[Tasks]
|
||||
Name: modifypath; Description: "&Add to Path"
|
||||
|
||||
[Code]
|
||||
const
|
||||
MODIFY_PATH_TASK_NAME = 'modifypath'; // Specify name of task
|
||||
|
||||
var
|
||||
PathIsModified: Boolean; // Cache task selection from previous installs
|
||||
ApplicationUninstalled: Boolean; // Has application been uninstalled?
|
||||
|
||||
// Import AddDirToPath() at setup time ('files:' prefix)
|
||||
function DLLAddDirToPath(DirName: string; PathType, AddType: DWORD): DWORD;
|
||||
external 'AddDirToPath@files:PathMgr.dll stdcall setuponly';
|
||||
|
||||
// Import RemoveDirFromPath() at uninstall time ('{app}\' prefix)
|
||||
function DLLRemoveDirFromPath(DirName: string; PathType: DWORD): DWORD;
|
||||
external 'RemoveDirFromPath@{app}\PathMgr.dll stdcall uninstallonly';
|
||||
|
||||
// Wrapper for AddDirToPath() DLL function
|
||||
function AddDirToPath(const DirName: string): DWORD;
|
||||
var
|
||||
PathType, AddType: DWORD;
|
||||
begin
|
||||
// PathType = 0 - use system Path
|
||||
// PathType = 1 - use user Path
|
||||
// AddType = 0 - add to end of Path
|
||||
// AddType = 1 - add to beginning of Path
|
||||
if IsAdminInstallMode() then
|
||||
PathType := 0
|
||||
else
|
||||
PathType := 1;
|
||||
AddType := 0;
|
||||
result := DLLAddDirToPath(DirName, PathType, AddType);
|
||||
end;
|
||||
|
||||
// Wrapper for RemoveDirFromPath() DLL function
|
||||
function RemoveDirFromPath(const DirName: string): DWORD;
|
||||
var
|
||||
PathType: DWORD;
|
||||
begin
|
||||
// PathType = 0 - use system Path
|
||||
// PathType = 1 - use user Path
|
||||
if IsAdminInstallMode() then
|
||||
PathType := 0
|
||||
else
|
||||
PathType := 1;
|
||||
result := DLLRemoveDirFromPath(DirName, PathType);
|
||||
end;
|
||||
|
||||
procedure RegisterPreviousData(PreviousDataKey: Integer);
|
||||
begin
|
||||
// Store previous or current task selection as custom user setting
|
||||
if PathIsModified or WizardIsTaskSelected(MODIFY_PATH_TASK_NAME) then
|
||||
SetPreviousData(PreviousDataKey, MODIFY_PATH_TASK_NAME, 'true');
|
||||
end;
|
||||
|
||||
function InitializeSetup(): Boolean;
|
||||
begin
|
||||
result := true;
|
||||
// Was task selected during a previous install?
|
||||
PathIsModified := GetPreviousData(MODIFY_PATH_TASK_NAME, '') = 'true';
|
||||
end;
|
||||
|
||||
function InitializeUninstall(): Boolean;
|
||||
begin
|
||||
result := true;
|
||||
// Was task selected during a previous install?
|
||||
PathIsModified := GetPreviousData(MODIFY_PATH_TASK_NAME, '') = 'true';
|
||||
ApplicationUninstalled := false;
|
||||
end;
|
||||
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
begin
|
||||
if CurStep = ssPostInstall then
|
||||
begin
|
||||
// Add app directory to Path at post-install step if task selected
|
||||
if PathIsModified or WizardIsTaskSelected(MODIFY_PATH_TASK_NAME) then
|
||||
AddDirToPath(ExpandConstant('{app}'));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
|
||||
begin
|
||||
if CurUninstallStep = usUninstall then
|
||||
begin
|
||||
// Remove app directory from path during uninstall if task was selected;
|
||||
// use variable because we can't use WizardIsTaskSelected() at uninstall
|
||||
if PathIsModified then
|
||||
RemoveDirFromPath(ExpandConstant('{app}'));
|
||||
end
|
||||
else if CurUninstallStep = usPostUninstall then
|
||||
begin
|
||||
ApplicationUninstalled := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure DeinitializeUninstall();
|
||||
begin
|
||||
if ApplicationUninstalled then
|
||||
begin
|
||||
// Unload and delete PathMgr.dll and remove app dir when uninstalling
|
||||
UnloadDLL(ExpandConstant('{app}\PathMgr.dll'));
|
||||
DeleteFile(ExpandConstant('{app}\PathMgr.dll'));
|
||||
RemoveDir(ExpandConstant('{app}'));
|
||||
end;
|
||||
end;
|
||||
; Copyright (C) 2021-2023 by Bill Stewart (bstewart at iname.com)
|
||||
;
|
||||
; This program is free software; you can redistribute it and/or modify it under
|
||||
; the terms of the GNU Lesser General Public License as published by the Free
|
||||
; Software Foundation; either version 3 of the License, or (at your option) any
|
||||
; later version.
|
||||
;
|
||||
; This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
; FOR A PARTICULAR PURPOSE. See the GNU General Lesser Public License for more
|
||||
; details.
|
||||
;
|
||||
; You should have received a copy of the GNU Lesser General Public License
|
||||
; along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
; Sample Inno Setup (https://www.jrsoftware.org/isinfo.php) script
|
||||
; demonstrating use of PathMgr.dll.
|
||||
;
|
||||
; This script uses PathMgr.dll in the following ways:
|
||||
; * Copies PathMgr.dll to the target machine (required for uninstall)
|
||||
; * Defines a task in [Tasks] that should modify the Path
|
||||
; * Imports the AddDirToPath() DLL function at setup time
|
||||
; * Imports the RemoveDirFromPath() DLL function at uninstall time
|
||||
; * Stores task state as custom setting using RegisterPreviousData()
|
||||
; * Retrieves task state custom setting during setup and uninstall initialize
|
||||
; * At post install, adds app dir to Path if task selected
|
||||
; * At uninstall, removes dir from Path if custom setting present
|
||||
; * Unloads and deletes DLL and removes app dir at uninstall deinitialize
|
||||
|
||||
#if Ver < EncodeVer(6,0,0,0)
|
||||
#error This script requires Inno Setup 6 or later
|
||||
#endif
|
||||
|
||||
[Setup]
|
||||
AppId={{A17D2D05-C729-4F2A-9CC7-E04906C5A842}
|
||||
AppName=EditPath
|
||||
AppVersion=4.0.4.0
|
||||
UsePreviousAppDir=false
|
||||
DefaultDirName={autopf}\EditPath
|
||||
Uninstallable=true
|
||||
OutputDir=.
|
||||
OutputBaseFilename=EditPath_Setup
|
||||
ArchitecturesInstallIn64BitMode=x64
|
||||
PrivilegesRequired=none
|
||||
PrivilegesRequiredOverridesAllowed=dialog
|
||||
|
||||
[Files]
|
||||
; Install PathMgr.dll for use with both setup and uninstall; use
|
||||
; uninsneveruninstall flag because DeinitializeSetup() will delete after
|
||||
; unloading the DLL; install the 32-bit version of PathMgr.dll because both
|
||||
; setup and uninstall executables are 32-bit
|
||||
Source: "i386\PathMgr.dll"; DestDir: "{app}"; Flags: uninsneveruninstall
|
||||
|
||||
; Other files to install on target system
|
||||
Source: "i386\EditPath.exe"; DestDir: "{app}"; Check: not Is64BitInstallMode()
|
||||
Source: "x86_64\EditPath.exe"; DestDir: "{app}"; Check: Is64BitInstallMode()
|
||||
Source: "EditPath.md"; DestDir: "{app}"
|
||||
|
||||
[Tasks]
|
||||
Name: modifypath; Description: "&Add to Path"
|
||||
|
||||
[Code]
|
||||
const
|
||||
MODIFY_PATH_TASK_NAME = 'modifypath'; // Specify name of task
|
||||
|
||||
var
|
||||
PathIsModified: Boolean; // Cache task selection from previous installs
|
||||
ApplicationUninstalled: Boolean; // Has application been uninstalled?
|
||||
|
||||
// Import AddDirToPath() at setup time ('files:' prefix)
|
||||
function DLLAddDirToPath(DirName: string; PathType, AddType: DWORD): DWORD;
|
||||
external 'AddDirToPath@files:PathMgr.dll stdcall setuponly';
|
||||
|
||||
// Import RemoveDirFromPath() at uninstall time ('{app}\' prefix)
|
||||
function DLLRemoveDirFromPath(DirName: string; PathType: DWORD): DWORD;
|
||||
external 'RemoveDirFromPath@{app}\PathMgr.dll stdcall uninstallonly';
|
||||
|
||||
// Wrapper for AddDirToPath() DLL function
|
||||
function AddDirToPath(const DirName: string): DWORD;
|
||||
var
|
||||
PathType, AddType: DWORD;
|
||||
begin
|
||||
// PathType = 0 - use system Path
|
||||
// PathType = 1 - use user Path
|
||||
// AddType = 0 - add to end of Path
|
||||
// AddType = 1 - add to beginning of Path
|
||||
if IsAdminInstallMode() then
|
||||
PathType := 0
|
||||
else
|
||||
PathType := 1;
|
||||
AddType := 0;
|
||||
result := DLLAddDirToPath(DirName, PathType, AddType);
|
||||
end;
|
||||
|
||||
// Wrapper for RemoveDirFromPath() DLL function
|
||||
function RemoveDirFromPath(const DirName: string): DWORD;
|
||||
var
|
||||
PathType: DWORD;
|
||||
begin
|
||||
// PathType = 0 - use system Path
|
||||
// PathType = 1 - use user Path
|
||||
if IsAdminInstallMode() then
|
||||
PathType := 0
|
||||
else
|
||||
PathType := 1;
|
||||
result := DLLRemoveDirFromPath(DirName, PathType);
|
||||
end;
|
||||
|
||||
procedure RegisterPreviousData(PreviousDataKey: Integer);
|
||||
begin
|
||||
// Store previous or current task selection as custom user setting
|
||||
if PathIsModified or WizardIsTaskSelected(MODIFY_PATH_TASK_NAME) then
|
||||
SetPreviousData(PreviousDataKey, MODIFY_PATH_TASK_NAME, 'true');
|
||||
end;
|
||||
|
||||
function InitializeSetup(): Boolean;
|
||||
begin
|
||||
result := true;
|
||||
// Was task selected during a previous install?
|
||||
PathIsModified := GetPreviousData(MODIFY_PATH_TASK_NAME, '') = 'true';
|
||||
end;
|
||||
|
||||
function InitializeUninstall(): Boolean;
|
||||
begin
|
||||
result := true;
|
||||
// Was task selected during a previous install?
|
||||
PathIsModified := GetPreviousData(MODIFY_PATH_TASK_NAME, '') = 'true';
|
||||
ApplicationUninstalled := false;
|
||||
end;
|
||||
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
begin
|
||||
if CurStep = ssPostInstall then
|
||||
begin
|
||||
// Add app directory to Path at post-install step if task selected
|
||||
if PathIsModified or WizardIsTaskSelected(MODIFY_PATH_TASK_NAME) then
|
||||
AddDirToPath(ExpandConstant('{app}'));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
|
||||
begin
|
||||
if CurUninstallStep = usUninstall then
|
||||
begin
|
||||
// Remove app directory from path during uninstall if task was selected;
|
||||
// use variable because we can't use WizardIsTaskSelected() at uninstall
|
||||
if PathIsModified then
|
||||
RemoveDirFromPath(ExpandConstant('{app}'));
|
||||
end
|
||||
else if CurUninstallStep = usPostUninstall then
|
||||
begin
|
||||
ApplicationUninstalled := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure DeinitializeUninstall();
|
||||
begin
|
||||
if ApplicationUninstalled then
|
||||
begin
|
||||
// Unload and delete PathMgr.dll and remove app dir when uninstalling
|
||||
UnloadDLL(ExpandConstant('{app}\PathMgr.dll'));
|
||||
DeleteFile(ExpandConstant('{app}\PathMgr.dll'));
|
||||
RemoveDir(ExpandConstant('{app}'));
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -1,118 +1,118 @@
|
||||
# EditPath
|
||||
|
||||
EditPath is a Windows console (text-based, command-line) program for managing the system Path and user Path.
|
||||
|
||||
# Author
|
||||
|
||||
Bill Stewart - bstewart at iname dot com
|
||||
|
||||
# License
|
||||
|
||||
EditPath.exe is covered by the GNU Lesser Public License (LPGL). See the file `LICENSE` for details.
|
||||
|
||||
# Download
|
||||
|
||||
https://github.com/Bill-Stewart/PathMgr/releases/
|
||||
|
||||
# Background
|
||||
|
||||
The system Path is found in the following location in the Windows registry:
|
||||
|
||||
Root: `HKEY_LOCAL_MACHINE`
|
||||
Subkey: `SYSTEM\CurrentControlSet\Control\Session Manager\Environment`
|
||||
Value name: `Path`
|
||||
|
||||
The current user Path is found in the following location in the registry:
|
||||
|
||||
Root: `HKEY_CURRENT_USER`
|
||||
Subkey: `Environment`
|
||||
Value name: `Path`
|
||||
|
||||
In both cases, the `Path` value is (or should be) the registry type `REG_EXPAND_SZ`, which means that it is a string that can contain values surrounded by `%` characters that Windows will automatically expand to environment variable values. (For example, `%SystemRoot%` will be expanded to `C:\Windows` on most systems.)
|
||||
|
||||
The `Path` value contains a `;`-delimited list of directory names that the system should search for executables, library files, scripts, etc. Windows appends the content of the current user Path to the system Path and expands the environment variable references. The resulting string is set as the `Path` environment variable for processes.
|
||||
|
||||
EditPath provides a command-line interface for managing the `Path` value in the system location (in `HKEY_LOCAL_MACHINE`) and the current user location (in `HKEY_CURRENT_USER`).
|
||||
|
||||
# Usage
|
||||
|
||||
The following describes the command-line usage for the program. Parameters are case-sensitive.
|
||||
|
||||
**EditPath** [_options_] _type_ _action_
|
||||
|
||||
You must specify only one of the following _type_ parameters:
|
||||
|
||||
| _type_ | Abbreviation | Description
|
||||
| ------- | ------------ | -----------
|
||||
| **--system** | **-s** | Specifies the system Path
|
||||
| **--user** | **-u** | Specifies the user Path
|
||||
|
||||
You must specify only one of the following _action_ parameters:
|
||||
|
||||
| _action_ | Abbreviation | Description
|
||||
| -------- | ------------ | -----------
|
||||
| **--list** | **-l** | Lists directories in Path
|
||||
| **--test "**_dirname_**"** | **-t "**_dirname_**"** | Tests if directory exists in Path
|
||||
| **--add "**_dirname_**"** | **-a "**_dirname_**"** | Adds directory to Path
|
||||
| **--remove "**_dirname_**"** | **-r "**_dirname_**"** | Removes directory from Path
|
||||
|
||||
The following parameters are optional:
|
||||
|
||||
| _options_ | Abbreviation | Description
|
||||
| --------- | ------------ | -----------
|
||||
| **--quiet** | **-q** | Suppresses result messages
|
||||
| **--expand** | **-x** | Expands environment variables (**--list** only)
|
||||
| **--beginning** | **-b** | Adds to beginning of Path (**--add** only)
|
||||
|
||||
# Exit Codes
|
||||
|
||||
The following table lists typical exit codes when not using **--test** (**-t**).
|
||||
|
||||
| Exit Code | Description
|
||||
| --------- | -----------
|
||||
| 0 | No errors
|
||||
| 2 | The Path value is not present in the registry
|
||||
| 3 | The specified directory does not exist in the Path
|
||||
| 5 | Access is denied
|
||||
| 87 | Incorrect parameter(s)
|
||||
| 183 | The specified directory already exists in the Path
|
||||
|
||||
The following table lists typical exit codes when using **--test** (**-t**).
|
||||
|
||||
| Exit Code | Description
|
||||
| --------- | -----------
|
||||
| 1 | The specified directory exists in the unexpanded Path
|
||||
| 2 | The specified directory exists in the expanded Path
|
||||
| 3 | The specified directory does not exist in the Path
|
||||
|
||||
# Remarks
|
||||
|
||||
* Anything on the command line after **--test**, **--add**, or **--remove** is considered to be the argument for the parameter. To avoid ambiguity, specify the _action_ parameter last on the command line.
|
||||
|
||||
* Uexpanded vs. expanded refers to whether the environment variable references (i.e., names between `%` characters) are expanded after retrieving the Path value from the registry. For example, `%SystemRoot%` is unexpanded but `C:\Windows` is expanded.
|
||||
|
||||
* The **--add** (**-a**) parameter checks whether the specified directory exists in both the unexpanded and expanded copies of the Path before adding the directory. For example, if the environment variable `TESTAPP` is set to `C:\TestApp` and `%TESTAPP%` is in the Path, specifying `--add C:\TestApp` will return exit code 183 (i.e., the directory already exists in the Path) because `%TESTAPP%` expands to `C:\TestApp`.
|
||||
|
||||
* The **--remove** (**-r**) parameter does not expand environment variable references. For example, if the environment variable `TESTAPP` is set to `C:\TestApp` and `%TESTAPP%` is in the Path, specifying `--remove "C:\TestApp"` will return exit code 3 (i.e., the directory does not exist in the Path) because **--remove** does not expand `%TESTAPP%` to `C:\TestApp`. For the command to succeed, you would have to specify `--remove "%TESTAPP%"` instead.
|
||||
|
||||
* The program will exit with error code 87 if a parameter (or an argument to a parameter) is missing or not valid, if mutually exclusive parameters are specified, etc.
|
||||
|
||||
* The program will exit with error code 5 if the current user does not have permission to update the Path value in the registry (for example, if you try to update the system Path using a standard user account or an unelevated administrator account).
|
||||
|
||||
# Examples
|
||||
|
||||
1. `EditPath --expand --system --list`
|
||||
|
||||
This command outputs the directories in the system Path, with environment variables expanded. You can also write this command as `EditPath -x -s -l`.
|
||||
|
||||
2. `EditPath --user --add "%LOCALAPPDATA%\Programs\MyApp"`
|
||||
|
||||
Adds the specified directory name to the user Path.
|
||||
|
||||
3. `EditPath -s -r "C:\Program Files\MyApp\bin"`
|
||||
|
||||
Removes the specified directory from the system Path.
|
||||
|
||||
4. `EditPath -s --test "C:\Program Files (x86)\MyApp\bin"`
|
||||
|
||||
Returns an exit code of 3 if the specified directory is not in the system Path, 1 if the specified directory is in the unexpanded copy of the system Path, or 2 if the specified directory is in the expanded copy of the system Path.
|
||||
# EditPath
|
||||
|
||||
EditPath is a Windows console (text-based, command-line) program for managing the system Path and user Path.
|
||||
|
||||
# Author
|
||||
|
||||
Bill Stewart - bstewart at iname dot com
|
||||
|
||||
# License
|
||||
|
||||
EditPath.exe is covered by the GNU Lesser Public License (LPGL). See the file `LICENSE` for details.
|
||||
|
||||
# Download
|
||||
|
||||
https://github.com/Bill-Stewart/PathMgr/releases/
|
||||
|
||||
# Background
|
||||
|
||||
The system Path is found in the following location in the Windows registry:
|
||||
|
||||
Root: `HKEY_LOCAL_MACHINE`
|
||||
Subkey: `SYSTEM\CurrentControlSet\Control\Session Manager\Environment`
|
||||
Value name: `Path`
|
||||
|
||||
The current user Path is found in the following location in the registry:
|
||||
|
||||
Root: `HKEY_CURRENT_USER`
|
||||
Subkey: `Environment`
|
||||
Value name: `Path`
|
||||
|
||||
In both cases, the `Path` value is (or should be) the registry type `REG_EXPAND_SZ`, which means that it is a string that can contain values surrounded by `%` characters that Windows will automatically expand to environment variable values. (For example, `%SystemRoot%` will be expanded to `C:\Windows` on most systems.)
|
||||
|
||||
The `Path` value contains a `;`-delimited list of directory names that the system should search for executables, library files, scripts, etc. Windows appends the content of the current user Path to the system Path and expands the environment variable references. The resulting string is set as the `Path` environment variable for processes.
|
||||
|
||||
EditPath provides a command-line interface for managing the `Path` value in the system location (in `HKEY_LOCAL_MACHINE`) and the current user location (in `HKEY_CURRENT_USER`).
|
||||
|
||||
# Usage
|
||||
|
||||
The following describes the command-line usage for the program. Parameters are case-sensitive.
|
||||
|
||||
**EditPath** [_options_] _type_ _action_
|
||||
|
||||
You must specify only one of the following _type_ parameters:
|
||||
|
||||
| _type_ | Abbreviation | Description
|
||||
| ------- | ------------ | -----------
|
||||
| **--system** | **-s** | Specifies the system Path
|
||||
| **--user** | **-u** | Specifies the user Path
|
||||
|
||||
You must specify only one of the following _action_ parameters:
|
||||
|
||||
| _action_ | Abbreviation | Description
|
||||
| -------- | ------------ | -----------
|
||||
| **--list** | **-l** | Lists directories in Path
|
||||
| **--test "**_dirname_**"** | **-t "**_dirname_**"** | Tests if directory exists in Path
|
||||
| **--add "**_dirname_**"** | **-a "**_dirname_**"** | Adds directory to Path
|
||||
| **--remove "**_dirname_**"** | **-r "**_dirname_**"** | Removes directory from Path
|
||||
|
||||
The following parameters are optional:
|
||||
|
||||
| _options_ | Abbreviation | Description
|
||||
| --------- | ------------ | -----------
|
||||
| **--quiet** | **-q** | Suppresses result messages
|
||||
| **--expand** | **-x** | Expands environment variables (**--list** only)
|
||||
| **--beginning** | **-b** | Adds to beginning of Path (**--add** only)
|
||||
|
||||
# Exit Codes
|
||||
|
||||
The following table lists typical exit codes when not using **--test** (**-t**).
|
||||
|
||||
| Exit Code | Description
|
||||
| --------- | -----------
|
||||
| 0 | No errors
|
||||
| 2 | The Path value is not present in the registry
|
||||
| 3 | The specified directory does not exist in the Path
|
||||
| 5 | Access is denied
|
||||
| 87 | Incorrect parameter(s)
|
||||
| 183 | The specified directory already exists in the Path
|
||||
|
||||
The following table lists typical exit codes when using **--test** (**-t**).
|
||||
|
||||
| Exit Code | Description
|
||||
| --------- | -----------
|
||||
| 1 | The specified directory exists in the unexpanded Path
|
||||
| 2 | The specified directory exists in the expanded Path
|
||||
| 3 | The specified directory does not exist in the Path
|
||||
|
||||
# Remarks
|
||||
|
||||
* Anything on the command line after **--test**, **--add**, or **--remove** is considered to be the argument for the parameter. To avoid ambiguity, specify the _action_ parameter last on the command line.
|
||||
|
||||
* Uexpanded vs. expanded refers to whether the environment variable references (i.e., names between `%` characters) are expanded after retrieving the Path value from the registry. For example, `%SystemRoot%` is unexpanded but `C:\Windows` is expanded.
|
||||
|
||||
* The **--add** (**-a**) parameter checks whether the specified directory exists in both the unexpanded and expanded copies of the Path before adding the directory. For example, if the environment variable `TESTAPP` is set to `C:\TestApp` and `%TESTAPP%` is in the Path, specifying `--add C:\TestApp` will return exit code 183 (i.e., the directory already exists in the Path) because `%TESTAPP%` expands to `C:\TestApp`.
|
||||
|
||||
* The **--remove** (**-r**) parameter does not expand environment variable references. For example, if the environment variable `TESTAPP` is set to `C:\TestApp` and `%TESTAPP%` is in the Path, specifying `--remove "C:\TestApp"` will return exit code 3 (i.e., the directory does not exist in the Path) because **--remove** does not expand `%TESTAPP%` to `C:\TestApp`. For the command to succeed, you would have to specify `--remove "%TESTAPP%"` instead.
|
||||
|
||||
* The program will exit with error code 87 if a parameter (or an argument to a parameter) is missing or not valid, if mutually exclusive parameters are specified, etc.
|
||||
|
||||
* The program will exit with error code 5 if the current user does not have permission to update the Path value in the registry (for example, if you try to update the system Path using a standard user account or an unelevated administrator account).
|
||||
|
||||
# Examples
|
||||
|
||||
1. `EditPath --expand --system --list`
|
||||
|
||||
This command outputs the directories in the system Path, with environment variables expanded. You can also write this command as `EditPath -x -s -l`.
|
||||
|
||||
2. `EditPath --user --add "%LOCALAPPDATA%\Programs\MyApp"`
|
||||
|
||||
Adds the specified directory name to the user Path.
|
||||
|
||||
3. `EditPath -s -r "C:\Program Files\MyApp\bin"`
|
||||
|
||||
Removes the specified directory from the system Path.
|
||||
|
||||
4. `EditPath -s --test "C:\Program Files (x86)\MyApp\bin"`
|
||||
|
||||
Returns an exit code of 3 if the specified directory is not in the system Path, 1 if the specified directory is in the unexpanded copy of the system Path, or 2 if the specified directory is in the expanded copy of the system Path.
|
||||
|
||||
Reference in New Issue
Block a user