X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=sudo%2FREADME.md;fp=sudo%2FREADME.md;h=c32661fe5dba4cb93506574bdf5184be2888e745;hb=5a31bc4a46158230203d68bec1e5768bc644bbb1;hp=0000000000000000000000000000000000000000;hpb=2f21911ba0eb028e6bb34597f412540ba520896e;p=webi-installers%2F.git diff --git a/sudo/README.md b/sudo/README.md new file mode 100644 index 0000000..c32661f --- /dev/null +++ b/sudo/README.md @@ -0,0 +1,33 @@ +--- +title: Sudo for Windows +homepage: https://stackoverflow.com/a/40321310/151312 +tagline: | + Sudo for Windows gives you a minimal `sudo` that works in cmd.exe and PowerShell. +--- + +## Cheat Sheet + +> Sudo for Windows isn't real `sudo`, but it's close enough for certain tasks - +> like installing WSL (the Windows Subsystem for Linux), without opening a GUI +> to Alt-Click "Run as Administrator". + +### Example: Enabling WSL + +```bash +sudo.cmd dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart +``` + +### Raw PowerShell + +`sudo.cmd` is simply an alias of a powershell elevation command: + +```pwsh +@echo off +powershell -Command "Start-Process cmd -Verb RunAs -ArgumentList '/c cd /d %CD% && %*'" +@echo on +``` + +Note: replace `/c` with `/k` if you'd like the window to stay open rather than +closing automatically. + +Source: