https://github.com/sangafabrice/add-to-path
Simple shortcut menus to modify the PATH environment variable on Windows.
https://github.com/sangafabrice/add-to-path
advanced-query-syntax environment-variables shortcut-menu windows-registry windows-script-host windows-shell
Last synced: 3 months ago
JSON representation
Simple shortcut menus to modify the PATH environment variable on Windows.
- Host: GitHub
- URL: https://github.com/sangafabrice/add-to-path
- Owner: sangafabrice
- Created: 2022-03-10T23:02:56.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-26T08:29:53.000Z (about 3 years ago)
- Last Synced: 2025-01-15T23:42:53.745Z (5 months ago)
- Topics: advanced-query-syntax, environment-variables, shortcut-menu, windows-registry, windows-script-host, windows-shell
- Language: VBScript
- Homepage:
- Size: 18.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
- jimsghstars - sangafabrice/add-to-path - Simple shortcut menus to modify the PATH environment variable on Windows. (VBScript)
README
# **The Add-To-Path utility**
---
##### Author: Fabrice Sanga
Simple utility to modify the PATH environment variable on Windows. It makes use of context menus to access the variable and change it. The shell objects involved are the directory and the directory background which keys are located under *HKEY_CURRENT_USER\SOFTWARE\Classes\Directory* within the Windows registry.
The concept is simple, the environment variables are all located in *HKEY_CURRENT_USER\Environment\Path* when only available to the current user, and *HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path* for system-wide variables. So the script reads and updates the `Path` value names at the user's wish. The script handles the changes to the context menus accordingly.
The utility is built in a way that makes the updates of system variables silent. This means the User Access Control (UAC) does not prompt for administrator privileges. It proceeds uninterrupted.
This is how it looks:
__1. A folder that is not on the PATH variable__

__2. A folder that is on the PATH variable__

The conditional display of the options is made using Advanced Query Syntax (AQS) on the implemented verbs. It helps include and exclude directories. Another project will work on context handlers. The canonical queries make extensive use of the `System.ItemPathDisplay` property that connects to the folder path. Just what is needed. And a chain of conjunction and disjunction associations does the trick. It is a complicated way to mean `AND` and `OR` operators.
__3. The folder background__

The utility allows to add a set of directories at the same time and the set is identified by a `PathID` (7z, git, ...). The checkmark notifies that all the folders in the set are on the `PATH`. *Reset all* reverts the environment variable to a predefined set of folders.
---
The usage of the script is as follows using a *Windows Scripting Host*, either `cscript` or `wscript` since it is all *VBScript*.
* To set up the utility.
```
wscript.exe set-path.vbs /install
```
* To register a set of directories
```
wscript.exe set-path.vbs PathID /install [/user:Path[;...]] /system:Path[;...]
wscript.exe set-path.vbs PathID /install /user:Path[;...] [/system:Path[;...]]PathID The set of paths identifiers
/user Registers the set of directories as only
available to the current user
/system Registers the set of directories as
available to every user
```
* To add or remove a group of directories with a path identifier
```
wscript.exe set-path.vbs [-|+]PathID [/elevate]+ Adds the set of directories to PATH
the option is the default.
- Removes the set of directories from PATH
/elevate to run as administrator
```
* To add or remove a group of directories with no path identifier
```
wscript.exe set-path.vbs -[FolderPath[;...]] [/path] [/elevate]
wscript.exe set-path.vbs [+][FolderPath[;...]] [/path[:{system|user}]] [/elevate]FolderPath The directory path to add or remove
```
* To reset path
```
wscript.exe set-path.vbs /reset [/elevate]
```