Top
JohnKlann / Posts tagged "set"

How to Set Environment Path Variables

Yay another powershell tip. Super useful and you could script it out if you want to carry around your custom environment paths and install them on any windows machine.

Admin PowerShell Prompt:

  1. Command Syntax:
     $pathtext=Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "Path" | %{$_.Path}
    $pathtext+=";c:\your\new\path\"
    Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "Path" -Value "$pathtext" 
  2. Example adding Cygwin bin directory:
     $pathtext=Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "Path" | %{$_.Path}
    $pathtext+=";c:\dev\cyg\bin\" 
    Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "Path" -Value "$pathtext" 
  3. Output:
  4. windows_powershell_ps_setting_windows_environment_path
  5. Logoff and Back in for it to take effect.
    shutdown /l

 

jklann

How to add environment Paths via command line (cmd, powershell)

Here’s a quick one lol.

Quick Note: This will temporarily set the Environment path with in that shell. If you want a more permanent solution you will have to added through windows environment variables config then logoff and back in.

  1. In CMD or Powershell prompt Run this command:
    1. Syntax:
       PATH %PATH%;c:\path\you\want\to\add\ 
  2. Example Using Cygwin Bin directory:
     PATH %PATH%;c:\dev\cyg\bin\ 
  3. Output:

windows_command_prompt_cmd_powershell_prompt_ps_set_environement_path

jklann