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

Allow to open different windows with different permissions #6560

Closed
MullenStudio opened this issue May 19, 2016 · 86 comments
Closed

Allow to open different windows with different permissions #6560

MullenStudio opened this issue May 19, 2016 · 86 comments
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code under-discussion Issue is under discussion for relevance, priority, approach workbench-run-as-admin Issues concerning running as administrator
Milestone

Comments

@MullenStudio
Copy link

  • VSCode Version: 1.1.1
  • OS Version: Windows 10 1511 (10586.318)

Steps to Reproduce:

  1. Close all Code instances, then run Code as administrator (a new blank Code instance with administrator right)
  2. In File Explorer, right click a text file and Open with Code, nothing will happen.

Note: there are multiple other ways to trigger this issue, the above repro is just an example.
Note 2: If you already have a code instance running without administrator running, the above issue will not get triggered. That's why the very first step is to close all Code instances.

@joaomoreno joaomoreno assigned bpasero and unassigned joaomoreno May 24, 2016
@bpasero bpasero changed the title If I aleady open an instance with administrator right, I can't open new instance without administrator right Allow to open different windows with different permissions May 24, 2016
@bpasero bpasero added feature-request Request for new features or functionality workbench labels May 24, 2016
@bpasero bpasero added this to the Backlog milestone May 24, 2016
@bpasero
Copy link
Member

bpasero commented May 24, 2016

I would say this is impossible today given our process architecture.

@StarTether
Copy link
Member

Why is this impossible? Is there a way to make it possible?

@rainersigwald
Copy link
Member

Would it be possible to include the elevation status in the pipe name so there are two parallel pipes for elevated and non-elevated processes?

@DfernandezNipo
Copy link

Hi. If you try to open a file in VS Code from command line using -r option to reuse existing window still fails if you have opened it using admin rights.

@johlju
Copy link

johlju commented Jun 6, 2017

Opening VS Code as elevated administrator in Windows. Then open an elevated PowerShell prompt and movide to a folder, then issue code . will open the folder in VS Code in a new window. But if the PowerShell prompt is not elevated this does not work. I was expecting it to open in a new window, but not elevated.

@demali
Copy link

demali commented Oct 16, 2017

I didn't remember if my last code window was opened as admin and I was unable to open a new window running code . until I read this issue. Is there a way to know that code is running in admin mode? I don't see it on the title bar.

@ryansimmen
Copy link
Member

The workaround for this is to force code to always run as administrator by right clicking on the exe, going to Properties, clicking on the Compatibility tab and check the box labeled "Run this program as an administrator".

@ghost
Copy link

ghost commented Apr 1, 2018

When there is no vscode process running, if you first open a file/folder as:

  • non-admin, then open as admin, then non-admin again.. it works
  • admin, then open as non-admin, it chokes with the error

The error is coming from:

https://github.com/Microsoft/vscode/blob/397b45b76dba2e9f0520664d1527b3d526fe4ae7/src/vs/code/electron-main/main.ts#L226-L233

In case of EPERM, should it try to launch a new process? The code above this line would need to be changed to support array PIDs.

@ghost
Copy link

ghost commented Apr 1, 2018

Maybe we should look at other electron-based apps, how they are handling multiple instances on windows and fix this issue. This is hurting the user experience. I had a demo effect with this one, which silenced the audience who were otherwise applauding the use of VSCode and it's code path/to/file shortcut..

@spakh
Copy link

spakh commented Apr 6, 2018

This just happenned to me as well. "A second instance of Code is already running as administrator".

Baffling that this happens. Posting it just to update the date on the thread that the issue is still around. Running on Windows 7 x64 (Powershell 3.0) using Code version 1.21.1

@brandonchastain
Copy link

+1 also happening to me. I'm confused by this thread. Is this behavior by-design or incorrect? I figure a text editor should be able to have as many instances as I want.

@justin-romano
Copy link

It is annoying but its funny how we all complain about it but none's submitted a pull request. ;-)

@bmarwell
Copy link

It is annoying but its funny how we all complain about it but none's submitted a pull request. ;-)

Not every user running into this has the skills to do so. I certainly don't, I am a java dev. Others may be python devs etc.

Anyway, most of us would be happy with a workaround provided by Microsoft.

@matthewacme
Copy link

6 years old and STILL no fix.

This is really silly.

@chenyukang
Copy link

Aha, This bug let us meet at this corner~

@justin-romano
Copy link

justin-romano commented Aug 24, 2022 via email

@ajlashenske
Copy link

ajlashenske commented Sep 16, 2022

I just ran into this because when I start a new code document, I typically type: code somesourcefile.c .py or whatever. Then in separate directory I click on a source file to look at a different piece of code and BAM! I get this pop-error. So apparently I cannot work in one directory where I need admin privs and a completely different directory where I don't. This is a really annoying feature!

@justin-romano
Copy link

I know. I can't see why they don't just request elevation by shutting down all code instances and relaunch elevated. You will get a uac prompt and off you go. Easy

@bpasero bpasero added the *out-of-scope Posted issue is not in scope of VS Code label Dec 6, 2022
@vscodenpa
Copy link

We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding, and happy coding!

@vscodenpa vscodenpa closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2022
@bmarwell
Copy link

bmarwell commented Dec 6, 2022

Ah. It is not intended to run VS Code on Terminal Servers? That should at least be worth a note in the README file. 🤔

@fourthborngoose
Copy link

You don't plan to address this issue? It is a critical feature for those of us who are required to run in both non-elevated and elevated environments due to security requirements? Do you have, perhaps, a best practices guideline that we could at least try to follow so that we can work?

@CDTR-MattConroy
Copy link

Not addressing this issue is ridiculous. Simply having an elevated instance open should not preclude me from opening anything else. At the very least, present some options to allow the user to proceed, opening the requested file in the same elevated instance or open a new non-elevated instance automatically. At the moment the workflow is halted because VS Code simply says "no".

@justin-romano
Copy link

"Computer says no"
image

@justin-romano
Copy link

I'm threatening a pull request. In my world, there is no such think as "can't". VS Code is a pretty good product as everyone here would openly testify to but this is annoying and I would like more of an explanation as to WHY? this is not an easy fix. Is it a node binding limitation? an election no-no? maybe some limitation in the portability of the framework. I have not looked into it but i would be happy to discuss this issue with a developer that does. Maybe I could help.

@merrelld
Copy link

merrelld commented Mar 15, 2023

Installing the system version as opposed to user version seemed to do the trick for me. Couldn't even fully uninstall user version due to user/appdata/local/programs permission issues.

EDIT: Nevermind, a few opens later the issue came back up. Notepad++ it is.

@AjayVV
Copy link

AjayVV commented Mar 24, 2023

As a developer, I want to know why is this impossible? It's not that it cannot open in Admin or non-Admin at all. I can open:

  • Notepad and Notepad++ as admin and non-admin (and any number of instances)
  • Visual Studio - any instances, even as System!

I just noticed one thing that if VSCode is opened from PS, then some debug logs keep showing that is probably coming from VSCode. Is that pipe-to-console connection preventing it? If so, why to connect it ?

@Torsteinws
Copy link

Torsteinws commented Apr 19, 2023

So what's the chance of this opening again? This issue is truly a deal breaker.

@kakugiki
Copy link

You can enable the compatibility tab on Windows by "Edit Group Policy". Then from the compatibility tab you can check the box "Run this program as an administrator". You'll need to restart your PC. It works on Windows 10 and 11.

@james-woodbridge
Copy link

Then from the compatibility tab you can check the box "Run this program as an administrator". You'll need to restart your PC. It works on Windows 10 and 11.

Can confirm that this workaround from @kakugiki works. Full steps below:

  1. Search for vscode in the start menu and right-click, select "open file location"
  2. A new explorer window opens with the shortcut, right-click and select "properties"
  3. Navigate to "Compatibility" tab
  4. Under "Settings" check the "Run this program as an administrator" option
  5. Click OK or Apply
  6. You should no be able to run multiple instances as administrator - if not, try restarting your PC.

@DfernandezNipo
Copy link

Then from the compatibility tab you can check the box "Run this program as an administrator". You'll need to restart your PC. It works on Windows 10 and 11.

Can confirm that this workaround from @kakugiki works. Full steps below:

  1. Search for vscode in the start menu and right-click, select "open file location"
  2. A new explorer window opens with the shortcut, right-click and select "properties"
  3. Navigate to "Compatibility" tab
  4. Under "Settings" check the "Run this program as an administrator" option
  5. Click OK or Apply
  6. You should no be able to run multiple instances as administrator - if not, try restarting your PC.

Executing always as administrator IS NOT a workaround.

@OMortensen
Copy link

Umm. It's now mid-2023. Please fix this already. I really need to have multiple CODE instances running as admin on Windows. Please make EVERY instance of Code use its own settings or whatever file. It's not that hard if you already support multiple instances of non-elevated execution.

@EdgeCaseLord
Copy link

Defining Code.exe to always run as administrator fixed this issue for me, but it should actually be the standard behaviour.

@kadirgun
Copy link

image

@DaveSenn
Copy link

This is just silly. It's time to fix this behavior.

@alexander-bet
Copy link

Then from the compatibility tab you can check the box "Run this program as an administrator". You'll need to restart your PC. It works on Windows 10 and 11.

Can confirm that this workaround from @kakugiki works. Full steps below:

  1. Search for vscode in the start menu and right-click, select "open file location"
  2. A new explorer window opens with the shortcut, right-click and select "properties"
  3. Navigate to "Compatibility" tab
  4. Under "Settings" check the "Run this program as an administrator" option
  5. Click OK or Apply
  6. You should no be able to run multiple instances as administrator - if not, try restarting your PC.

Thank you very much! It works for me too

@ataraxyarcane
Copy link

I believe @johlju 's comment could be considered a type of workaround if you want to have multiple elevated VS Code instances with different directories.

Opening VS Code as elevated administrator in Windows. Then open an elevated PowerShell prompt and navigate to the folder, then issue code . will open the folder in VS Code in a new window. But if the PowerShell prompt is not elevated this does not work. I was expecting it to open in a new window, but not elevated.

So,

  1. Opening VS Code as an admin.
  2. Starting an elevated Powershell/Terminal/Command Prompt (and navigating to the directory you want to open in VS).
  3. Running code . opens that directory in VS Code in a new, elevated window and doesn't trigger a message saying you can't have multiple admin windows open.

Just something that worked for my situation.

@codewizard13
Copy link

Defining Code.exe to always run as administrator fixed this issue for me, but it should actually be the standard behaviour.

That seemed to work for me also, however I later discovered this causes problems with other local development software (e.g., LocalWP/Local Flywheel). So, while this approach appears to fix one issue, it likely will cause other things to break.

@TFWol
Copy link

TFWol commented Nov 20, 2024

Defining Code.exe to always run as administrator fixed this issue for me, but it should actually be the standard behaviour.

That seemed to work for me also, however I later discovered this causes problems with other local development software (e.g., LocalWP/Local Flywheel). So, while this approach appears to fix one issue, it likely will cause other things to break.

Exactly

@nikfio
Copy link

nikfio commented Dec 8, 2024

image

Thank you @kadirgun! this fixed my case I had for so long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code under-discussion Issue is under discussion for relevance, priority, approach workbench-run-as-admin Issues concerning running as administrator
Projects
None yet
Development

No branches or pull requests