Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolatey#2044) Fix for changing $env:Temp
Running as `SYSTEM`, the `$env:Temp` variable is normally *C:\Windows\Temp*. If the **first** package to ever use `Update-SessionEnvironment.ps1` happens to be running as `SYSTEM`, the location of `$env:Temp` changes to *C:\Windows\system32\config\systemprofile\AppData\Local\Temp* for the duration of the session. This change to `$env:Temp` does not occur in subsequent calls to `Update-SessionEnvironment.ps1`. It is unknown why this change occurs at all and likewise is unknown why it occurs for only the first time. The `Update-SessionEnvironment.ps1` normally gives priority to user-scope environment variables over machine-scope environment variables. Changes in this commit eliminates the gathering of the `User` scope environment variables when running as the `SYSTEM` account on the belief that reason to be operating under the `SYSTEM` account is to do machine-wide activities, and there is no reason to see `SYSTEM` as a "user". On a clean system, the only User-scope environment variables under `SYSTEM` are *path*, *temp*, and *tmp* which are already defined under the Machine-scope, and in general, there shouldn't be any new User-scope variables for the SYSTEM account because it's not a "normal" account. Basically, there should be little reason to expect this change to break anything.
- Loading branch information