Last active
September 29, 2023 16:22
-
-
Save wheelerlaw/a426fb609715a2c7cc156c6aabb6076f to your computer and use it in GitHub Desktop.
Running elevated commands from a non-elevated git-bash with the ability to pipe/redirect the output of the elevated command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
elevate() { | |
powershell -Command "Start-Process cmd -ArgumentList \"/c\",\"$1 2>&1 | clip\" -Verb RunAs" | |
powershell -sta "add-type -as System.Windows.Forms; [windows.forms.clipboard]::GetText()" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment