Changing the PATH variable in PowerShell 5.1

This $ENV:PATH holds the value of your current PATH settings. This variable can be updated in your current PowerShell terminal :

$ENV:PATH="$ENV:PATH;C:\Program Files (x86)\Notepad++"

You can also retrieve the current value with the following cmdlet Get-ItemProperty :

Get-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment’ -Name PATH

To make this change permanently, open up a new PowerShell terminal as Administrator (using runas) :


$oldpath = (Get-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment’ -Name PATH).Path

$newpath = "$oldpath;C:\Program Files (x86)\Notepad++"

Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment’ -Name PATH -Value $newpath

Now, just log out of your current Windows session to take this change into account

NB : Tested successfully on Windows 10

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.