Show HN: Sudo for Windows

  • If you're at the command line anyway, Powershell is nearly always a better choice, and it has that covered also. See TokenDiversity 's comment, or use a simple function or use Invoke-Elevated from an installable package. E.g. https://stackoverflow.com/questions/1566969/showing-the-uac-...

    Or if you know the admin account you could use something like

        Invoke-Command -ScriptBlock { ls } -ComputerName $env:COMPUTERNAME -Credential (Get-Credential)

  • There's also a "sudo" for windows distributed as a chocolatey package that I've used for at least a year. Appears to do pretty much the same thing as this one.

    https://chocolatey.org/packages/Sudo

  • I've always been annoyed by the lack of ability for certain things to elevate as needed. Why doesn't Notepad offer to let you elevate when you try and save the hosts file?

    I can't count how often I relaunch Command Prompt to Run as Admin.

    But I'm hesitant to use a third party tool here, I really wish Microsoft just dealt with this properly.

  • Hi, all.

    I'm author. I added this because I want to write hosts file with ":w !sudo tee %" from gvim.exe on Windows. But most of implementations doesn't work for this.

  • I literally wrote something identical just over a week ago; even called it sudo as well. Mine's in .NET as a little EXE. It's about 10 lines of code. I am not dissing this effort though. Far from it. Open Source is cool.

    It's annoying that you still have to navigate the UAC dialog though - not sure how to get around that, without compromising security.

    For those talking about right-click on the EXE... If you live in the command prompt, having to reach for the mouse just to elevate is irritating as hell.

  • I don't understand Windows permissions well but if anybody looking to do this without a dpendencey.. I think

    `Start-Process <stuff> -verb RunAs` does the same

  • Nice as a learning project, but RunAs is already supported at CLI and GUI level, since several versions.

    For those without much Windows GUI-fu, shift-right click.

  • This is actually very useful, will save me time reopening terminal sessions

  • I just use this 6 kb no-dependencies command line program:

    http://code.kliu.org/misc/elevate/

  • Is it really sudo? Does it remember credentials somewhere for a limited time and across the whole system? If so, I cant see a way to implement it securely if you're not MS.

  • There is also a sudo for scoop http://scoop.sh/

  • There is also CPAU where you can store the elevated command as a sort of batch file http://www.joeware.net/freetools/tools/cpau/

  • All of this can be done with a bit of vbscript, no need to install anything

  • I'm using

      cygstart --action=runas
    
    This works well, too.

  • Isn't this more like "su" instead of "sudo"?

    (and it would spare two key strokes ;)