9

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 ?

8
  • 2
    Try opening VS Code as administrator, this may provide admin privileges to the terminal as well, I guess. Commented Oct 3, 2017 at 12:09
  • No; 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.
    – Ramhound
    Commented Oct 3, 2017 at 14:03
  • Have 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.
    – root
    Commented Oct 3, 2017 at 14:41
  • @Ĭsααctիεβöss VSC is started with standard priviledges. If I start it with Admin priviledges, powershell will have admin too. Thank you Commented Oct 4, 2017 at 10:16
  • @root VCS has a bunch of settings for terminal, but not the one to start the powershell as admin. Commented Oct 4, 2017 at 10:16

1 Answer 1

13

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. enter image description here

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.

1
  • 6
    This 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.
    – JW0914
    Commented Aug 19, 2019 at 11:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .