Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RefreshEnv / Update-SessionEnvironment changes current user to SYSTEM #902

Closed
gunnarvelle opened this issue Aug 11, 2016 · 9 comments
Closed

Comments

@gunnarvelle
Copy link

What You Are Seeing?

If I run RefreshEnv.cmd in a ConEmu cmd-shell the current user is changed to SYSTEM in the environment variable USERNAME. This leads to the PATH to be broken.

What is Expected?

I'd expect the USERNAME to remain unchanged.

How Did You Get This To Happen? (Steps to Reproduce)

Ran RefreshEnv, both in regular cmd and in elevated cmd.

Output Log

My prompt shows the current user, so thats why I noticed.

gv@GVPC C:\Users\gv

RefreshEnv.cmd
Reading environment variables from registry. Please wait... Done.

SYSTEM@GVPC C:\Users\gv

@ferventcoder
Copy link
Member

What version of Chocolatey here?

@ferventcoder
Copy link
Member

Actually, I do think this is likely an issue. I know that it is one thing we've dealt with in the c# code that does the same, and we need to add those changes to both the powershell and batch versions

@gunnarvelle
Copy link
Author

Choco versjon is 0.9.10.3.

@rmlephiew
Copy link
Contributor

I'd like to work on this one

@ferventcoder
Copy link
Member

@rmlephiew go for it - read over the entire CONTRIBUTING doc first and ensure you can sign the CLA. We get somewhat picky about git commit message formatting, but that is covered in the doc. So as long as you follow the format you should be good to go.

@splatteredbits
Copy link
Contributor

I'm having a similar issue with the Chocolatey installer. If I install chocolatey, the USERNAME environment variable gets changed to SYSTEM. Is this the same underlying cause? Or should I enter another issue?

Steps to Reproduce:

  1. Boot a computer that doesn't have Chocolatey installed.
  2. Open a PowerShell prompt
  3. Inspect USERNAME environment varaible: > $env:USERNAME
  4. Install chocolatey: Invoke-WebRequest -Uri 'https://chocolatey.org/install.ps1' -UseBasicParsing | Invoke-Expression
  5. Inspect USERNAME environment variable and note that it is now SYSTEM: > $env:USERNAME.

@ferventcoder ferventcoder self-assigned this Feb 2, 2017
@ferventcoder ferventcoder modified the milestones: 0.10.4, 0.10.x Feb 2, 2017
@ferventcoder ferventcoder changed the title RefreshEnv changes current user to SYSTEM RefreshEnv / Update-SessionEnvironment changes current user to SYSTEM Feb 2, 2017
@splatteredbits
Copy link
Contributor

Update: turns out, it isn't the Chocolatey installer. I'm running Update-SessionEnvironment after the install. So, I am having this same problem.

@ferventcoder
Copy link
Member

@ferventcoder
Copy link
Member

Completed for 0.10.4.

ferventcoder added a commit that referenced this issue Mar 19, 2017
Previously, running RefreshEnv / Update-SessionEnvironment would change
current user to SYSTEM. This is due to Machine environment variables
noting user as SYSTEM. To stop this, set the original username as a
variable and reset the Username environment variable after the refresh.

Do the same for Processor_Architecture.
ferventcoder added a commit that referenced this issue Mar 19, 2017
* stable:
  (GH-1098) Get-FtpFile - change int to long / improve error handling
  (docs) update generated docs
  (GH-1187) Get-ChocolateyUnzip - support both archs
  (GH-1039) Remove quotes before testing path
  (GH-686) Upgrade Scenarios for Prereleases
  (GH-686) Upgrade Prereleases
  (GH-1151) Option - Stop on first package failure
  (GH-902) Fix: User changed to SYSTEM during env update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants