Windows – Open Windows Terminal as Admin with WIN+R

administratorwindowswindows 10windows-terminal

I use shortcut Windows Key +R to run Windows Terminal [wt], but I cannot run it as Admin, which causes problems when I install something via choco.

  • To open it as Admin, I have to:
    Press Windows Key > Right-click Terminal > More > Run as Admin > > ENTER
  • Some solutions say to use the following, but it can only open powershell, not wt:
    Windows Key+X > A > > ENTER
  • While others say to use the following, but it also doesn't work:
    Windows Key+R > SHIFT+CTRL+ENTER

How do I open Windows Terminal as Admin via a command?

Best Answer

A shell in Windows Terminal [wt] can be launched/relaunched as Admin in three ways:

  1. Pin Windows Terminal to the Taskbar → Shift + Right-click it → Run as Administrator
  2. Relaunch as Admin from within wt:
    # Cmd:
      Powershell -Command "Start-Process cmd -Verb RunAs"
    
    # Powershell:
      Start-Process -FilePath "powershell" -Verb RunAs
    
    # Pwsh:
      Start-Process -FilePath "pwsh" -Verb RunAs
    
    • These can be added as environment variables to PowerShell profiles [$Profile]:
      • %UserProfile%\Documents\Windows Powershell\Microsoft.PowerShell_profile.ps1
      • %UserProfile%\Documents\Windows Powershell\profile.ps1

  3. Add Relaunch-Admin function to profile, invoking with Relaunch-Admin or alias psadmin:
    # Function to relaunch as Admin:
      function Relaunch-Admin { Start-Process -Verb RunAs (Get-Process -Id $PID).Path }
    
    # Alias for the function:
      Set-Alias psadmin Relaunch-Admin