Allow to open different windows with different permissions
- VSCode Version: 1.1.1
- OS Version: Windows 10 1511 (10586.318)
Steps to Reproduce:
- Close all Code instances, then run Code as administrator (a new blank Code instance with administrator right)
- 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.
I would say this is impossible today given our process architecture.
Why is this impossible? Is there a way to make it possible?
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?
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.
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.
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.
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".
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.
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..
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
+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.
+1 also happening to me. Seems to be dependent on OS and UAC settings.
I'm curious what the status is on this? There are numerous other reports of this - all of them being closed as a dupe (some with links back to this, others with no links). I see this has been open for 2 years
Anyone looking at this?
I have only just started experiencing this problem since a recent update. Not sure if it was the recent windows creators update that has changed things or if it was a release of vscode. I don't specifically run as admin for the first copy, it seems to do it for itself, and then decides not to when I want to open a second file.
For now a sort of workaround, as mentioned above, is that I have set "run as admin" in the .exe properties, but this means I now have to click the yes prompt every time I open vscode.
When it does open, it opens into the same copy of vscode thats running, not a second instance.
Looking at the other highest voted issues being ignored by @bpasero and co., such as https://github.com/Microsoft/vscode/issues/10121, it doesn't seem like they care much. Even the pull requests are sitting there unmerged without any explanation for months/years.. Why would anyone spend time to fix this issue, open a pull-request and get ignored for the rest of my life? This project need serious love and better maintainers.
@kasper3 The workaround, as mentioned above (https://github.com/Microsoft/vscode/issues/6560#issuecomment-353100020) is to force vscode to always open as admin. There are clearly technical issues behind why this and #10121 haven't been implemented yet. It's definitely not true that the maintainers don't care.
Run this program as an administrator works for me.

This does not help for using the shell menu. That's the really annoying thing. Even if the shell menu elevated the session through UAC
On Tue, Jun 12, 2018 at 2:09 PM, Bright Chen [email protected] wrote:
Run this program as an administrator works for me. [image: image] https://user-images.githubusercontent.com/90078/41266204-82ca3368-6e28-11e8-8e88-a2e0d37a4cd8.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode/issues/6560#issuecomment-396442643, or mute the thread https://github.com/notifications/unsubscribe-auth/ABoM2j9K5vRAe0E_oAM0L7hEBhbTzg-Nks5t7yLQgaJpZM4IivsR .
-- Justin Romaine Senior Systems Architect Spark Dental Technology [email protected] ph 021 764 506 hm 09 445 9166
I know that running always as Administrator is a Microsoft tradition to solve some problems, but I want to run it with the minimum permissions that the program needs each time.