microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.46k stars 29.36k forks source link

Allow to open different windows with different permissions #6560

Closed MullenStudio closed 1 year ago

MullenStudio commented 8 years ago

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.

kasajian commented 3 years ago

I find it interesting that this is not considered a show-stopper bug. I was ready to stop using Visual Studio Code as my main editor until I saw the workaround by @ryansimmen for setting Code.exe to always run on Admin. This should either be the default or an option during install.

Does anyone know if vscodium has the same problem?

vatsan-madhavan commented 3 years ago

by creating a different user-data-directory (the place all our config etc. goes) depending on wether you run with elevated permissions or not. The reason is this:

As part of solving this problem, can you consider a rearchitecture that would maintain two parallel well-known user-data directories - one for elevated and another for non-elevated instance respective - and keep those in sync/merged automatically ?

code already has sync/merge capability for settings roaming, so perhaps that can be leveraged to sync/merge user-data across two local folders and deal with incoherencies between the two user-data instances.

HppZ commented 2 years ago

now 2022, is it still impossible mission?

hello-smile6 commented 2 years ago

Please! Just attempt to create a file in C:\Windows and delete it if it works. It's not that hard! If you have multiple sessions open, create two files, one for the elevated process and one for the non-elevated one. Make both watch each other's files and write data to their files, then delete them when they detect that there's nothing writing to the other file.

dmrickey commented 2 years ago

There are tons of solutions, just fix it already..

iamqiz commented 2 years ago

now 2022 ,the problem still exist 😢

bmarwell commented 2 years ago

Any update on this? This occurs on terminal servers, even though there is no admin login.

hassanpdn commented 2 years ago

Now 2022 is going to be finished, the problem still exist.

justin-romano commented 2 years ago

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

bmarwell commented 2 years ago

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 commented 2 years ago

6 years old and STILL no fix.

This is really silly.

chenyukang commented 2 years ago

Aha, This bug let us meet at this corner~

justin-romano commented 2 years ago

The eternal flame!

On Wed, Aug 24, 2022 at 10:54 PM Yukang @.***> wrote:

Aha, This bug let us meet at this corner~

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/6560#issuecomment-1225557575, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANAZWXVOSJRVFN4B7F2GG3V2X5ONANCNFSM4CEK7MIQ . You are receiving this because you commented.Message ID: @.***>

-- Justin Romaine Senior Architect Titanium Solutions Ltd. @.*** +64 21 764 506 hm 09 445 9166

ajlashenske commented 2 years ago

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 commented 2 years ago

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

vscodenpa commented 1 year ago

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!

bmarwell commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

"Computer says no" image

justin-romano commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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:

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 commented 1 year ago

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

kakugiki commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

kadirgun commented 1 year ago

image

DaveSenn commented 1 year ago

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

alexander-bet commented 1 year ago

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 commented 5 months ago

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.