Add "sudo" tool/command in cmd/PowerShell
On *nix you can run a command from a non-root shell, which is the equivalent of a non-administrator Command Prompt, with administrative privileges, similar to what UAC does when it asks a user if they would like to give an application administrative privileges. To disable a network adapter, for example, you can run "sudo ifconfig eth0 down". The prefixed "sudo" command will run "ifconfig eth0 down" with what is essentially administrator privileges in Windows. Currently you have to do some long-winded (long-typed?) "runas", which requires that a username and password are provided. I don't necessarily need Command Prompt to always run as administrator, I just need SOME of the commands I to run as administrator.
We have it on our backlog, definitely. —Rich
Sudo for Windows (sudowin) has been around for a L-O-O-O-G time and works very nicely.
I've been using it for ages. Its just there for the picking on https://sourceforge.net/projects/sudowin/
It allows authorized users to launch processes with elevated privileges using their own passphrase. Unlike the runas command, Sudo for Windows preserves the user's profile and ownership of created objects. This last is very important.
Simpson Bart commented
I've used elevate.exe for quite a while.
seems pointless to me. Just have two windows open, or shell out and back... Spend the time developing good things.
Note that there's other request for a sudo: https://wpdev.uservoice.com/forums/266908-command-prompt/suggestions/6513096-keep-command-line-history-add-sudo-command.
Corinna Vinschen commented
As Cygwin maintainer I'd like to chime in here.
One problem with elevating from the command line is IO redirection and passing of handles.
The biggest problem with UAC from the CLI POV is that you have to use ShellExecuteEx to
elevate. What's desperately missing (here's definitely Cygwin speaking) is a lower level
call along the lines of CreateProcessAsUser, which works kind of backwards. Rather than
the caller having to have certain privileges, it should allow to run an elevated process from
a non-elevated user account. CreateProcessElevated or so.
The important point here is that this would allow to propagate all the things required in
a CLI environment, current working directory, process handles, stdio handles, while at
the same time allowing elevation. This could be used for any "su-like tool, not only
in the native Windows environment, but also in Cygwin and other POSIX-environments.
Kirill Illenseer commented
There's an elevate powertoy. Wouldn't it serve the purpose to integrate the elevate powertoy with Windows by default?
Some way of getting this, rather than "This command requires Administrative privileges" would be very useful.