$ | >

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.

271 votes
Sign in
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

Travis C Howard shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: facebook google
Signed in as (Sign out)
  • Andrew commented  ·   ·  Flag as inappropriate

    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.

  • Dave commented  ·   ·  Flag as inappropriate

    seems pointless to me. Just have two windows open, or shell out and back... Spend the time developing good things.

  • Corinna Vinschen commented  ·   ·  Flag as inappropriate


    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  ·   ·  Flag as inappropriate

    There's an elevate powertoy. Wouldn't it serve the purpose to integrate the elevate powertoy with Windows by default?

  • Dave commented  ·   ·  Flag as inappropriate

    Some way of getting this, rather than "This command requires Administrative privileges" would be very useful.

Feedback and Knowledge Base