Skip to content

Instantly share code, notes, and snippets.

@dpwright
Last active December 26, 2015 04:28
Show Gist options
  • Save dpwright/7093085 to your computer and use it in GitHub Desktop.
Save dpwright/7093085 to your computer and use it in GitHub Desktop.
Overcoming Windows' bizarre ordering of %PATH% variables
# Windows constructs the %PATH% environment variable by appending the user
# PATH to the system PATH, which means you can't override system-level programs
# with your own, user-specific version.
# To fix this, save this script and set it to run on logon by following these
# instructions: http://technet.microsoft.com/en-us/library/cc770908.aspx
# (If step 1 is a mystery to you, go to Start->Run and type "gpedit.msc")
# Requires Windows 7
# If your path is longer than 1024 characters, this might not work :-(
$sysPath = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path).Path
$userPath = (Get-ItemProperty -Path 'HKCU:\Environment' -Name Path).Path
setx path "$userPath;$sysPath" /m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment