Skip to content

Instantly share code, notes, and snippets.

@IncognitaDev
Last active September 25, 2023 20:23
Show Gist options
  • Save IncognitaDev/50186a49a3fb3356a094b9b359fbf301 to your computer and use it in GitHub Desktop.
Save IncognitaDev/50186a49a3fb3356a094b9b359fbf301 to your computer and use it in GitHub Desktop.
sudo command for windows powershell

Linux (for wsl users)

run

cd ~
touch winsu.ps1
notepad.exe winsu.ps1

paste:

#!/usr/bin/env -S powershell.exe -ExecutionPolicy Bypass
$program=$args[0]

Start-Process $program -Verb RunAs

make a alias

alias --save winsu=~/winsu.ps1  

Now its G2G

winsu notepad

For Powershell users

run

cd ~
New-Item winsu.ps1
notepad winsu.ps1

paste:

#!/usr/bin/env -S powershell.exe -ExecutionPolicy Bypass
$program=$args[0]

Start-Process $program -Verb RunAs

make a alias

notepad $profile

add this lines

$ps_script_dir = "~"

New-Alias winsu $ps_script_dir\winsu.ps1

Now its G2G

winsu notepad

NOTES

change ~ to your script path in case you dont create in user home dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment