Last active
September 23, 2023 22:13
-
-
Save cpuwolf/150920f87259c46fb9f318c61f294c3a to your computer and use it in GitHub Desktop.
run power shell script from batch file
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
::written by [email protected] 2023 Sep. | |
:: | |
::must run as administrator | |
@chcp 437 >nul 2>&1 | |
:: Add value for UAC shield icon: | |
REG ADD "HKCR\Microsoft.PowerShellScript.1\Shell\runas" /v HasLUAShield /t REG_SZ /d "" /f | |
:: Add value to create context menu item: | |
REG ADD "HKCR\Microsoft.PowerShellScript.1\Shell\runas\command" /ve /t REG_EXPAND_SZ /d "\"%%SYSTEMROOT%%\System32\WindowsPowerShell\v1.0\powershell.exe\" -executionpolicy bypass -nologo -file \"%%1\"" /f | |
@cd /d "%~dp0" | |
@NET SESSION >nul 2>&1 | |
@IF %ERRORLEVEL% EQU 0 ( | |
@powershell.exe -ExecutionPolicy bypass -File %~dp0qmdevfw.ps1 | |
) ELSE ( | |
@ECHO Error! Please run as administrator! | |
pause | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment