Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: Add "Open PowerShell window here as administrator" context menu in Windows 10 and Windows 11
- @Echo Off & Cls
- (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
- :choice
- Cls & Mode CON LINES=11 COLS=95 & Color 0E & Title Created By FreeBooter
- Echo.
- Echo.
- Echo.
- Echo Add "Open PowerShell window here as administrator" to Context Menu (A)
- Echo.
- Echo Remove "Open PowerShell window here as administrator" from Context Menu (R)
- Echo.
- Set /p input=^>
- If /i Not %input%==A (Goto :_Ex) Else (Goto :_Add)
- :_Ex
- If /i Not %input%==R (Goto :choice) Else (Goto :_Remove)
- :_Add
- Reg.exe add "HKCR\Directory\Background\shell\PowerShellAsAdmin" /ve /t REG_SZ /d "Open PowerShell window here as administrator" /f
- Reg.exe delete "HKCR\Directory\Background\shell\PowerShellAsAdmin" /v "Extended" /f
- Reg.exe add "HKCR\Directory\Background\shell\PowerShellAsAdmin" /v "HasLUAShield" /t REG_SZ /d "" /f
- Reg.exe add "HKCR\Directory\Background\shell\PowerShellAsAdmin" /v "Icon" /t REG_SZ /d "powershell.exe" /f
- Reg.exe add "HKCR\Directory\Background\shell\PowerShellAsAdmin\command" /ve /t REG_SZ /d "PowerShell -Command \"Start-Process cmd -ArgumentList '/s,/k,pushd %%V && start PowerShell -NoExit && exit' -Verb RunAs\"" /f
- Reg.exe add "HKCR\Directory\shell\PowerShellAsAdmin" /ve /t REG_SZ /d "Open PowerShell window here as administrator" /f
- Reg.exe delete "HKCR\Directory\shell\PowerShellAsAdmin" /v "Extended" /f
- Reg.exe add "HKCR\Directory\shell\PowerShellAsAdmin" /v "HasLUAShield" /t REG_SZ /d "" /f
- Reg.exe add "HKCR\Directory\shell\PowerShellAsAdmin" /v "Icon" /t REG_SZ /d "powershell.exe" /f
- Reg.exe add "HKCR\Directory\shell\PowerShellAsAdmin\command" /ve /t REG_SZ /d "PowerShell -Command \"Start-Process cmd -ArgumentList '/s,/k,pushd %%V && start PowerShell -NoExit && exit' -Verb RunAs\"" /f
- Reg.exe add "HKCR\Drive\shell\PowerShellAsAdmin" /ve /t REG_SZ /d "Open PowerShell window here as administrator" /f
- Reg.exe delete "HKCR\Drive\shell\PowerShellAsAdmin" /v "Extended" /f
- Reg.exe add "HKCR\Drive\shell\PowerShellAsAdmin" /v "HasLUAShield" /t REG_SZ /d "" /f
- Reg.exe add "HKCR\Drive\shell\PowerShellAsAdmin" /v "Icon" /t REG_SZ /d "powershell.exe" /f
- Reg.exe add "HKCR\Drive\shell\PowerShellAsAdmin\command" /ve /t REG_SZ /d "PowerShell -Command \"Start-Process cmd -ArgumentList '/s,/k,pushd %%V && start PowerShell -NoExit && exit' -Verb RunAs\"" /f
- Reg.exe delete "HKCR\LibraryFolder\Background\shell\PowerShellAsAdmin" /f
- REM ; To allow mapped drives to be available in elevated PowerShell
- Reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLinkedConnections" /t REG_DWORD /d "1" /f
- Goto :RestartEx
- :_Remove
- Reg.exe delete "HKCR\Directory\Background\shell\PowerShellAsAdmin" /f
- Reg.exe delete "HKCR\Directory\shell\PowerShellAsAdmin" /f
- Reg.exe delete "HKCR\Drive\shell\PowerShellAsAdmin" /f
- Reg.exe delete "HKCR\LibraryFolder\Background\shell\PowerShellAsAdmin" /f
- :RestartEx
- Taskkill /im Explorer.exe /f >Nul
- Start Explorer.exe
- Exit
Add Comment
Please, Sign In to add comment