PowerTip: Set Personal Environment Variable from PowerShell

Doctor Scripto

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.

0 comments

Discussion is closed.

Feedback usabilla icon