By using this site, you agree to the Privacy Policy.
Accept
EnterinITEnterinITEnterinIT
  • HOME
  • IT PRO
  • TECH
  • MICROSOFT
    • Azure
    • ConfigMgr/SCCM
    • DPM
    • Orchestrator
    • Hyper-V
    • Microsoft Edge Insider
    • MSI
    • Office 365
    • Office Insider
    • Power BI
    • Skype
    • SQL Server
    • Teams
  • WINDOWS
    • Windows Admin Center
    • Windows Client
    • Windows Server
  • SCCM Query Collection List
Reading: PowerShell add Windows PATH variable using setx
Font ResizerAa
EnterinITEnterinIT
Font ResizerAa
  • HOME
  • IT PRO
  • TECH
  • MICROSOFT
  • WINDOWS
  • SCCM Query Collection List
Search
  • HOME
  • IT PRO
  • TECH
  • MICROSOFT
    • Azure
    • ConfigMgr/SCCM
    • DPM
    • Orchestrator
    • Hyper-V
    • Microsoft Edge Insider
    • MSI
    • Office 365
    • Office Insider
    • Power BI
    • Skype
    • SQL Server
    • Teams
  • WINDOWS
    • Windows Admin Center
    • Windows Client
    • Windows Server
  • SCCM Query Collection List
IT Pro

PowerShell add Windows PATH variable using setx

Published: February 18, 2024
2 Min Read
SHARE

PowerShell add Windows PATH variable using setx.

Run Powershell as Administrator

setx /M PATH "$Env:PATH;"

To verify

$Env:PATH

NOTE: In Windows 10 unless ‘/m’ is the very first argument rather than the last, the variable is set in the logged-in user’s context not the machine’s.

Remarks

  • The Setx command is similar to the UNIX utility SETENV.
  • Setx provides the only command-line or programmatic way to directly and permanently set system environment values. System environment variables are manually configurable through Control Panel or through a registry editor. The set command, which is internal to the command interpreter (Cmd.exe), sets user environment variables for the current console window only.
  • You can use the setx command to set values for user and system environment variables from one of three sources (modes): Command Line Mode, Registry Mode, or File Mode.
  • Setx writes variables to the master environment in the registry. Variables set with setx variables are available in future command windows only, not in the current command window.
  • HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE are the only supported hives. REG_DWORD, REG_EXPAND_SZ, REG_SZ, and REG_MULTI_SZ are the valid RegKey data types.
  • When you gain access to REG_MULTI_SZ values in the registry, only the first item is extracted and used.
  • You cannot use the setx command to remove values that have been added to the local or system environments. You can use set with a variable name and no value to remove a corresponding value from the local environment.
  • REG_DWORD registry values are extracted and used in hexadecimal mode.
  • File mode supports the parsing of carriage return and line feed (CRLF) text files only.
TAGGED:PowerShellWindowsWindows 10
Previous Article How to Stop a Stuck Hyper-V Virtual Machine
Next Article New features announced for Office 365 for 2019/20
Leave a Comment Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

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

Translation

English中文(简体)DanskNederlandsFrançaisDeutschItaliano한국어PolskiPortuguêsRomânăEspañolУкраїнська
by Transposh - translation plugin for wordpress

Popular Posts

System Requirements for Windows Server 2016
Windows Server
Configuration Manager Query Collection List
Configuration Manager Query Collection List
ConfigMgr
Structured/Managed Navigation enabled on Modern Pages in Classic Team Sites
Tech
SCCM Failed to get DP locations as the expected version from MP
ConfigMgr

Recent Posts

Installing and Configuring Fail2ban for SSH Protection on Ubuntu 24.04
Linux
Enabling and Configuring FirewallD on AlmaLinux
Linux
User Creation and SSH Key Setup in AlmaLinux
Linux
How to reset password on AlmaLinux
Linux

© 2023 EnterinIT

Go to mobile version
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?