Sudo for Windows
You know how you get this sort of permission error in Windows console?
PS> mkdir "c:\program files\new" mkdir : Access to the path 'new' is denied.
And you know how the ‘solution’ is to start up a whole new console with Start > [program] > Right-click > ‘Run as administrator’? And how you have to ‘cd’ back to where you were, and you don’t have access to the shell session you were working with?
Have you ever wished you could just ‘sudo <whatever command just failed>’, like you can on other operating systems? I kept wishing this, almost daily; until finally I couldn’t take it any longer and created a sudo for Windows.
- All your text in the one window
- Works with interactive prompts
- Shows colored output (if output isn't being redirected)
- HINT: quick-confirm the UAC popup with Alt-Y and your hands never have to leave the keyboard (*doesn't always work for some reason)
- Written in Powershell. Works from cmd.exe too, if installed with Scoop (command will be executed under Powershell).
- Can redirect output. Need to escape redirection operators with backticks, e.g.:
sudo echo "hello" `> out.txt # or sudo echo "hello" 2`>`&1 `> out.txt
If you don't already have Scoop, you need to install that first (using Powershell):
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser irm get.scoop.sh | iex
Then, to install sudo itself:
scoop install sudo