Add Open in Windows Terminal as Administrator to Context menu in Windows 10 and Windows 11 with Batch Script


FreeBooter

Well-known member
Guru
VIP
Local time
8:56 AM
Posts
5,468
OS
Windows 11
You can add Open in Windows Terminal as Administrator to Context menu in Windows 10 and Windows 11 File Explorer, so this entry will allow you to open the Windows Terminal app elevated from the right-click menu in the current folder.



Batch:
::  Add Open in Windows Terminal as Administrator to Context menu in Windows 10 and Windows 11

@Echo Off

net sess>nul 2>&1||(powershell start cmd -ArgumentList """/c %~0""" -verb Runas & exit)

:_Start
Cls & Mode CON  LINES=13 COLS=90 & Color 0E
Echo.
Echo.      
Echo         Type (R) to Remove Open in Windows Terminal as Administrator
Echo.
Echo.        
Echo         Type (A) to Add Open in Windows Terminal as Administrator  
Echo.      
Echo.




Set /p input=:^>

If /i  Not %input%==R (Goto :_A) Else (Goto :_Remove)

:_A

If /i  Not %input%==A  (Goto :_Start) Else (Goto :_Add)





:_Add

Reg.exe add "HKCR\Directory\shell\WindowsTerminalAsAdmin" /v "HasLUAShield" /t REG_SZ /d "" /f
Reg.exe add "HKCR\Directory\shell\WindowsTerminalAsAdmin" /v "MUIVerb" /t REG_SZ /d "Open in Windows Terminal as Administrator" /f
Reg.exe add "HKCR\Directory\shell\WindowsTerminalAsAdmin" /v "SubCommands" /t REG_SZ /d "" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile" /v "MUIVerb" /t REG_SZ /d "Open in Windows Terminal as Administrator - Default Profile" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile" /v "HasLUAShield" /t REG_SZ /d "" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile\command" /ve /t REG_SZ /d "powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-d','.')\"" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\02Cmd" /v "MUIVerb" /t REG_SZ /d "Open in Windows Terminal as Administrator - Command Prompt" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\02Cmd" /v "Icon" /t REG_SZ /d "imageres.dll,-5324" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\02Cmd\command" /ve /t REG_SZ /d "powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','\"\"\"Command Prompt\"\"\"','-d','.')\"" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\03PS" /v "MUIVerb" /t REG_SZ /d "Open in Windows Terminal as Administrator - PowerShell" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\03PS" /v "HasLUAShield" /t REG_SZ /d "" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\03PS" /v "Icon" /t REG_SZ /d "powershell.exe" /f
Reg.exe add "HKCR\Directory\Shell\WindowsTerminalAsAdmin\shell\03PS\command" /ve /t REG_SZ /d "powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','\"\"\"Windows PowerShell\"\"\"','-d','.')\"" /f
REM ; Directory\Background
Reg.exe add "HKCR\Directory\Background\shell\WindowsTerminalAsAdmin" /v "HasLUAShield" /t REG_SZ /d "" /f
Reg.exe add "HKCR\Directory\Background\shell\WindowsTerminalAsAdmin" /v "MUIVerb" /t REG_SZ /d "Open in Windows Terminal as Administrator" /f
Reg.exe add "HKCR\Directory\Background\shell\WindowsTerminalAsAdmin" /v "SubCommands" /t REG_SZ /d "" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile" /v "MUIVerb" /t REG_SZ /d "Open in Windows Terminal as Administrator - Default Profile" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile" /v "HasLUAShield" /t REG_SZ /d "" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile\command" /ve /t REG_SZ /d "powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-d','.')\"" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\02Cmd" /v "MUIVerb" /t REG_SZ /d "Open in Windows Terminal as Administrator - Command Prompt" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\02Cmd" /v "Icon" /t REG_SZ /d "imageres.dll,-5324" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\02Cmd\command" /ve /t REG_SZ /d "powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','\"\"\"Command Prompt\"\"\"','-d','.')\"" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\03PS" /v "MUIVerb" /t REG_SZ /d "Open in Windows Terminal as Administrator - PowerShell" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\03PS" /v "HasLUAShield" /t REG_SZ /d "" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\03PS" /v "Icon" /t REG_SZ /d "powershell.exe" /f
Reg.exe add "HKCR\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\03PS\command" /ve /t REG_SZ /d "powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','\"\"\"Windows PowerShell\"\"\"','-d','.')\"" /f
Exit





:_Remove

Reg.exe delete "HKCR\Directory\shell\WindowsTerminalAsAdmin" /f
Reg.exe delete "HKCR\Directory\Background\shell\WindowsTerminalAsAdmin" /f
Exit
 

Attachments

My Computer My Computer

At a glance

Windows 11AMD Ryzen 7 5700GMicron Technology DDR4-3200 16GBNVIDIA GeForce RTX 3060
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
HP Pavilion
CPU
AMD Ryzen 7 5700G
Motherboard
Erica6
Memory
Micron Technology DDR4-3200 16GB
Graphics Card(s)
NVIDIA GeForce RTX 3060
Sound Card
Realtek ALC671
Monitor(s) Displays
Samsung SyncMaster U28E590
Screen Resolution
3840 x 2160
Hard Drives
SAMSUNG MZVLQ1T0HALB-000H1
Back
Top Bottom