sedwards2009 / extraterm

The swiss army chainsaw of terminal emulators
https://extraterm.org
MIT License
2.54k stars 115 forks source link

Feature request: Open windows shells, cmd, powershell as adminstrator #160

Open nelaaro opened 5 years ago

nelaaro commented 5 years ago

Hi guys,

Great app, this is what I have been looking for.

I have a feature request to add the ability to open new CMD, PowerShell terminals with administrator privileges.

Let me know how I can help with this. Testing etc.

sedwards2009 commented 5 years ago

I'm not a huge windows developer and any advice on how to go about implementing this would be welcome.

There seem to be a bunch of different approaches which may or may not be modern: https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows

nelaaro commented 5 years ago

I am going to fork and see what I can put together.

I am hoping to add additional option in the session type settings to "show run as administrator" in the 'command palette' . This should then show an additional option to run as administrator for those sessions that are enabled.

I see there are some nodejs / npm modules

https://www.npmjs.com/package/elevator https://www.npmjs.com/package/windows-elevate

In the mean time I have worked around my need for elevated privileges by making the extraterm exe run as administrator by default. This is not a perfect solution as it means all work I do in the term is now as administrator. Which does not follow the least privilege model.

sedwards2009 commented 5 years ago

When Extraterm starts cmd.exe or powershell etc, it doesn't run them directly the same way that those modules do. There is some hackery involved to start a hidden console window and run the command/shell in there. It is worth looking at the little utilities which those modules use. The solution may be as simple as running cmd.exe with the help of elevate.exe.

Also, some good news is that that part of the code is isolated in the 2 extensions/WindowsConsole* directories.