Add, delete, sort, and backup Windows environment variables including PATH.
- Automatic REG_SZ and REG_EXPAND_SZ detection
- Backup before you make any changes with
EnvUserBackup()andEnvSystemBackup() - Sort your messy Windows PATH in alphabetical order and remove duplicate entries.
- Edit both system and user path with separate commands.
- Broadcast changes to PATH in the current AutoHotKey script and System-wide.
- Supports relative paths with just in time conversion.
Create a new script with the following code.
#include Environment.ahk
Env_UserBackup(), Env_SystemBackup() ; Always backup!
MsgBox userpath := Env_UserRead("PATH") ; Display the user path.
Env_UserBackup()
Env_SystemBackup()
Env_UserAdd("PATH", "C:\bin")
Env_UserSub("PATH", "C:\bin")
Env_UserRemove("PATH", "C:\bin") ; Alias to above
Env_UserAdd("PATH", "..\project1\bin")
Env_UserTemp("PATH", "D:\Software\bin")
Env_UserAddFirst("PATH", ".\bin") ; Default behavior
Env_UserAddLast("PATH", ".\bin") ; Appends to the end
Env_UserAddSort("PATH", ".\bin") ; Sorts in alphabetical order
Env_UserAddUnique("PATH", ".\bin") ; Removes duplicates
Env_UserTempFirst("PATH", ".\bin")
Env_UserTempLast("PATH", ".\bin")
Env_UserAddFirstUnblock("PATH", ".\bin")
Env_UserAddLastUnblock("PATH", ".\bin")
Env_UserAddSortUnblock("PATH", ".\bin")
Env_UserAddUniqueUnblock("PATH", ".\bin")
Env_UserTempFirstUnblock("PATH", ".\bin")
Env_UserTempLastUnblock("PATH", ".\bin")
Env_RefreshEnvironment()
Env_SettingChange()
Env_UserTempFirstFast("GOPATH", ".\bin\go")
Env_UserTempFirstFast("PY", ".\bin\python.exe")
Env_UserTempFirstFast("JAVAFX", ".\java\javafx-sdk-11.0.2\lib")
; Then when you are ready to broadcast changes:
Env_RefreshEnvironment()
Env_SettingChange()
Env_UserNew("NUMBER_OF_GPU_CORES", "9")
key := Env_UserRead("NUMBER_OF_GPU_CORES")
; returns 9
Env_UserDel("NUMBER_OF_GPU_CORES")
Env_SystemAdd("PATH", "X:\Backup\bin")
Env_SystemSort("PATH")
Env_SystemUnique("PATH")