Give administrator privileges to existing powershell
Since my suggestion(comment) has worked for the OP, I'm posting this as an answer
Launch the VSCode as an administrator, so that the integrated powershell also gets the admin privileges as you expected.
Instead every time you right-click and "Run as administrator", navigate to the installation folder of the VSCode program, and do as the following demonstration shows.
Note: The files you create this way within VSCode are then also owned by the administrator. This probably isn't an issue in most of the cases. But there are scenarios where this, at least, creates a higher effort for you when handling those files.
Related videos on Youtube
Alex Huiculescu
Updated on September 18, 2022Comments
-
Alex Huiculescu over 1 year
Having a powershell opened, it's possible to give it administrator priviledges ?
It's embedded in an IDE (Visual Studio Code) and I don't want to open a new terminal everytime I do something that needs administrator priviledges (like npm install ... --save-dev)
If not, can I set VS Code to open terminals with administrator priviledges ?
-
Ĭsααc tիε βöss over 6 yearsTry opening VS Code as administrator, this may provide admin privileges to the terminal as well, I guess.
-
Ramhound over 6 yearsNo; In order for a process to have escalated permissions it must be started with escalated permissions. This is the reason whenever an application requests elevated permissions the process is relaunched.
-
root over 6 yearsHave you looked in VSC's User Settings? The path to PS is there, along with other PS parameters. Not sure if VSC launched with standard privileges could start a child process as admin, though.
-
Alex Huiculescu over 6 years@Ĭsααctիεβöss VSC is started with standard priviledges. If I start it with Admin priviledges, powershell will have admin too. Thank you
-
Alex Huiculescu over 6 years@root VCS has a bunch of settings for terminal, but not the one to start the powershell as admin.
-
Alex Huiculescu over 6 years@Ramhound can you give me some more details ? I just started Operating Systems course and I'd like to learn from the docs
-
root over 6 years@Ĭsααctիεβöss You should post this as an answer and the requester should accept this as an answer.
-
JW0914 over 4 yearsThis used to be able to be resolved as mentioned in this writeup, however I wasn't able to replicate using PowerShell 6 (with ConEmu, VS Code, or the new Terminal), however you should be able to do research on google to figure out what needs to be modified in the writeup's
Restart-Host
function. However, what should never be done is running VS Code with Admin privileges, as it allows arbitrary code from within VS Code to execute with admin privileges on the host << Massive Security Risk
-
-
JW0914 over 4 yearsThis is a massive security issue and would never be recommended for a myriad of reasons... first and foremost, it allows arbitrary code from with VS Code to execute with admin privileges on the host and is a recipe for disaster.