How to run 'sudo' command in windows
All the answers explain how to elevate your command in a new console host. So, I wrote: gsudo to behave like Unix/Linux sudo
, allowing to execute the command inside the current console.
gsudo
- Source Code, Documentation, and Releases available at: https://github.com/gerardog/gsudo
Most relevant features:
- Elevates in the current console (no new window)
- Elevates
cmd
commands, but also PowerShell / WSL / Git-Bash / cygwin / Msys / commands natively. - Optional: Credentials Cache (Elevate many times with only one UAC popup)
Installation
- Using scoop:
scoop install gsudo
- Using Chocolatey:
choco install gsudo
- Using Winget:
winget install gerardog.gsudo
- Manually: Download the latest release, unzip, and add to path, from https://github.com/gerardog/gsudo/releases/
Demo
There is no sudo
command in Windows. The nearest equivalent is "run as administrator."
You can do this using the runas
command with an administrator trust-level, or by right-clicking the program in the UI and choosing "run as administrator."