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

Windows: Prevent update service from activating if running as Admin in User install #148428

Closed
joaomoreno opened this issue Apr 29, 2022 · 12 comments · Fixed by #155631
Closed

Windows: Prevent update service from activating if running as Admin in User install #148428

joaomoreno opened this issue Apr 29, 2022 · 12 comments · Fixed by #155631
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders install-update VS Code installation and upgrade system issues verified Verification succeeded windows VS Code on Windows issues
Milestone

Comments

@joaomoreno
Copy link
Member

From #147763 (comment)

@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities install-update VS Code installation and upgrade system issues windows VS Code on Windows issues labels Apr 29, 2022
@joaomoreno joaomoreno added this to the Backlog milestone Apr 29, 2022
@joaomoreno joaomoreno self-assigned this Apr 29, 2022
@RussKie
Copy link
Member

RussKie commented May 2, 2022

Perhaps the update should not be run if there are any other Code instances are open.

@joaomoreno
Copy link
Member Author

That won't happen anyway unless they aren't sharing the same user data dir. Have you observed otherwise?

@benallred
Copy link

Added this on 147763, but probably should have put it here.

We might want to disable update in sessions started as Admin, when in the user setup. What do you think?

@joaomoreno: Just thought I should mention that running VS Code as admin is what enabled my VS Code to actually update in a user setup. #147408 (comment)

@joaomoreno
Copy link
Member Author

@joaomoreno: Just thought I should mention that running VS Code as admin is what enabled my VS Code to actually update in a user setup. #147408 (comment)

Yeah I'm aware of that. Is also theoretically what put you in that situation. Is it possible you ran Code like that prior to the bug happening? I'm currently investigating.

@benallred
Copy link

Is it possible you ran Code like that prior to the bug happening?

If you mean, ran as admin once and it updated while that instance was running, then, yes, that's possible. I never had the error on the linked issue happen before my winget switch, though, thus my suspicion there. On the other hand, where VS Code updates only happen once a month, it could just be that one-off runs as admin never coincided with an update. On the first hand, though, I have this problem on two machines now, since that switch, and it seems unlikely that I would have run as admin at the same time as the monthly update on two machines where I never had before. 🤷

@makemefeelgr8
Copy link

Please, do not implement this. It's going to break the only way there is to update User installations. #155043

@benallred
Copy link

Is it possible you ran Code like that prior to the bug happening?

I have this problem on two machines now, since that switch, and it seems unlikely that I would have run as admin at the same time as the monthly update on two machines where I never had before. 🤷

I'm running into this on a third machine that I know absolutely never runs Code as admin. (It is still installed as admin, but never run as admin.)

@gjsjohnmurray
Copy link
Contributor

gjsjohnmurray commented Jul 19, 2022

Possible code pointer for where to prevent update service from activating on Windows if running as Admin in User install? #155547 (comment)

gjsjohnmurray added a commit to gjsjohnmurray/vscode that referenced this issue Jul 19, 2022
joaomoreno added a commit that referenced this issue Jul 22, 2022
…as admin (#148428) (#155631)

* Try to prevent update of user-type Windows installation when running as admin (#148428)

* update win32: detect admin mode in initialize

Co-authored-by: João Moreno <[email protected]>
@VSCodeTriageBot VSCodeTriageBot added the unreleased Patch has not yet been released in VS Code Insiders label Jul 22, 2022
@joaomoreno
Copy link
Member Author

Verification:

  1. Install the user setup on Windows
  2. Launch Code as Admin
  3. Open the Main log and confirm updates are disabled

@VSCodeTriageBot VSCodeTriageBot removed the unreleased Patch has not yet been released in VS Code Insiders label Jul 25, 2022
@VSCodeTriageBot VSCodeTriageBot added the insiders-released Patch has been released in VS Code Insiders label Jul 25, 2022
@gjsjohnmurray
Copy link
Contributor

@joaomoreno this verifies on today's Insiders if no other instances of Code are running when I run as admin. But if I already have a normally-launched instance, the main log of a subsequent admin-launched instance doesn't report that message. Is this correct?

@joaomoreno
Copy link
Member Author

joaomoreno commented Jul 26, 2022

That's OK. The main process runs always using the permissions of the first launch. And the update service always runs on the main process.

Thanks for verifying!

@depascalis
Copy link

This solution doesn't work for me, I need to be running vscode elevated and always have been, same for my team members. I don't remember why, but after some days/weeks running vscode normally I always get reminded of why it was needed.

Could a solution be to prevent the update service only when vscode has a normal instance AND an elevated instance running at the same time? I believe this would make everyone happy. 🥳

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders install-update VS Code installation and upgrade system issues verified Verification succeeded windows VS Code on Windows issues
Projects
None yet
8 participants