Tyriar / vscode-shell-launcher

VS Code extension that enables easy launching of multiple shell configurations in the terminal
https://marketplace.visualstudio.com/items?itemName=Tyriar.shell-launcher
MIT License
49 stars 9 forks source link

Option to run various shells as Administrator #5

Open alexandruboboc opened 7 years ago

alexandruboboc commented 7 years ago

Hi. Love your plugin, thanks for offering it for free.

I am wondering, how could I run PowerShell as Administrator inside VSC?

From windows cmd, I can do this: powershell -Command "Start-Process PowerShell -Verb RunAs"

or I can run this when in PowerShell: Start-Process PowerShell -Verb RunAs.

and both sollutions give me a new PowerShell window as Administrator.

So I gave this a go:

        {
            "shell": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
            "args": ["Start-Process PowerShell -Verb RunAs"],
            "label": "PowerShell (Administrator)"
        }

And it starts a PowerShell terminal as Administrator, but in a new window outside of VSC.

Any suggestions?

Tyriar commented 7 years ago

I'd love to add this if we figure it out, the challenge is getting powershell/cmd to run as admin within the same window. My thinking here was that we'd need to use some combination of runas.exe, cmd /c or start to solve this generically.

soulshined commented 6 years ago

Hi there I know this is a year late, but I just skimmed through the issues on this repo and can offer a real simple workaround for future readers, that may or may not suit you. If you run Visual Code as administrator, that cascades down to the integrated, or otherwise, terminals. In other words, it inherits admin rights thanks to UAC. You can do this on a single instance of running, by right clicking VS Code + "run as administrator", or there or numerous ways you can google to always run Visual Code as administrator. Either way that you see fit, the terminal will also run as administrator.

I think this is probably a more suitable alternative, as you won't need to edit syntax for circumstantial workspace settings, but too each their own. Just a suggestion for those looking