January 2nd, 2016

PowerTip: Set Personal Environment Variable from PowerShell

Doctor Scripto
Scripter

Summary: Access the $ENV object in Windows PowerShell to alter personal environment settings.

Hey, Scripting Guy! Question How can I use Windows PowerShell to change a system environment variable such as the user %TEMP%?

Hey, Scripting Guy! Answer You can read any personal environment settings by using $ENV:VariableName, then assigning a value.
           For example, to change your personal %TEMP% to a new location, use:

$ENV:Temp=C:\Foo

Note This presumes C:\Foo exists and will alter the variable for the present PowerShell session.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback