To set an environment variable in PowerShell, use
$env:VAR_NAME = "value" for the current session or [System.Environment]::SetEnvironmentVariable() to save it permanently. 1. Temporary (Current Session Only)
Variables set this way apply only to your current terminal window and any programs launched from it. They disappear when you close PowerShell.
2. Permanent (Across Restarts)
On Windows, use the .NET
[System.Environment] class to save variables to the registry so they persist across sessions and reboots.- For your user account only:
- System-wide for all users (requires running PowerShell as Administrator:
No comments:
Post a Comment