Created
May 2, 2018 16:15
-
-
Save linnet8989/139229b18f3bc4fb354544b6eb674f3e to your computer and use it in GitHub Desktop.
run powershell.exe/cmd.exe as Administrator in powershell and use current working directory as its working directory
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
# open a new powershell | |
# full version: | |
$arg = '-NoExit -Command "& {cd '+ "'" + $pwd + "'"+ '}"' | |
Start-Process Powershell -ArgumentList $arg -Verb runAs | |
# simplified version: | |
$arg = '-noexit -c "& {cd '+ "'" + $pwd + "'"+ '}"' | |
start powershell -a $arg -v runas | |
# open a new cmd | |
# full version: | |
$arg = '/k cd "' + $pwd + '"' | |
Start-Process cmd -ArgumentList $arg -Verb runAs | |
# simplified version: | |
$arg = '/k cd "' + $pwd + '"' | |
start cmd -a $arg -v runas |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment