Open Windows Terminal as admin with WIN+R
Solution 1
I found a nice workaround.
If you use Chocolatey to install "sudo" you can use sudo to activate any command as admin from inside The windows terminal. It will launch a separate window (either cmd or PowerShell) and provide a UAC prompt if enabled.
Solution 2
A shell in Windows Terminal [wt
] can be launched/relaunched as Admin in three ways:
- Pin Windows Terminal to the Taskbar → Shift + Right-click it → Run as Administrator
-
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
- These can be added as environment variables to PowerShell profiles [
- Add
Relaunch-Admin
function to profile, invoking withRelaunch-Admin
or aliaspsadmin
:# 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
Solution 3
To start an executable as Admin from Run and Windows Menus, press CTRL+SHIFT+ENTER:
- Run: WinKey+R
-
Windows Menus: Type the app's name > Right-click it > Select Open file location:
- Right-click on shortcut > Select Properties
-
Shortcut tab > Advanced > Advanced Properties > Select Run as administrator
(The app will always start as Admin from now on)
Additional options to run an app as Administrator
Solution 4
You can create a shortcut to always run Windows Terminal as administrator using this powershell script:
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Home\Desktop\Windows Terminal.lnk")
$Shortcut.TargetPath = "$env:LOCALAPPDATA\Microsoft\WindowsApps\Microsoft.WindowsTerminal_8wekyb3d8bbwe\wt.exe"
$Shortcut.Save()
$bytes = [System.IO.File]::ReadAllBytes("$Home\Desktop\Windows Terminal.lnk")
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes("$Home\Desktop\Windows Terminal.lnk", $bytes)
It basically creates a Windows Terminal.lnk file on your desktop, when you run it runs Windows Terminal as an administrator.
Solution 5
In older versions of Windows, Run... created tasks with administrative privileges, but in Windows 10, it no longer does; however, you can do it using Task Manager:
- CTRL+SHIFT+ESC > File Menu > New task > Create task with administrative privileges
deuterium
Updated on September 18, 2022Comments
-
deuterium over 1 year
I use shortcut +R to run Windows Terminal [
wt
], but I cannot run it as Admin, which causes problems when I install something viachoco
.- To open it as Admin, I have to:
Press > Right-click Terminal > More > Run as Admin > ◀ > ENTER - Some solutions say to use the following, but it can only open
powershell
, notwt
:
+X > A > ◀ > ENTER - While others say to use the following, but it also doesn't work:
+R > SHIFT+CTRL+ENTER
How do I open Windows Terminal as Admin via a command?
-
Admin almost 4 yearsUsually, all you have to do is enter your command in the Run box, press Shift and click OK with the Shift key down.
-
deuterium almost 4 yearsi tried so,it does open the programme,but not as admin as i want.@Didier
-
Admin almost 4 yearsThere's no reason for it not to work: Ctrl-Enter is the keyboard equivalent of clicking on the OK button, and Shift gets you elevated rights. It sure works on my own Windows 10 when I'm logged on as regular user with admin rights. Are you sure you have local admin rights on this account? EDIT: this said, I haven't upgraded to 2004 yet.
-
deuterium almost 4 years@Didier yes,i'm using win 10 1909 as so.but it just not work as expected.seems i need to chect if it works on other computers. ps:my system is pre-installed with a laptop,will it influences?
-
Brad P. almost 3 yearsWhen you attempt to run Windows Key+R > SHIFT+CTRL+ENTER, presumably you type
wt
in the run box before pressing ctrl + shift + enter, right? I just tried it on windows 10 21h1 and that works for me to launch terminal as admin (and presumably anything I type in the run box as admin if I wanted...thanks for that tip!)
- To open it as Admin, I have to:
-
Admin almost 4 yearsMy method is way quicker, I dare say... :-)
-
deuterium almost 4 yearsthat is the problem.CTRL+SHIFT+ENTER does not work at all from Run.that is the perfect way i perfer,cause pther way rely on mouse move to some special place,which means not "fluent" for me.same happend so when i choose start menu(it needs some time to load)
-
deuterium almost 4 yearsi tried the second way,srom bad to worse,when i use start menu,system tells me he "has no access to the file" (not very sure,i'm not using a english system).luckily it is fixed after reinstall.
-
deuterium almost 4 yearsi'm searching for a way as fast as possible,which makes me have a sense of "fluent" i now opens startmenu and click,which seems even more faster then the method you offer.sorry~
-
Wasif almost 4 years@Didier u r way does not work! Notice deuterium's comment
-
JW0914 almost 4 yearsRegarding the link, the issue is
wt
doesn't work like other programs and appears to not have a way baked in to launch it as Admin outside of context menus. To determine for sure, it's GitHub page, man page, and issues page would need to be referenced, as Trying to launchwt
as Admin through normal means doesn't work. (please also use the correct markdown for weblinks =] ) -
deuterium almost 4 yearsyes,i'm using win 10 1909,you need not to assum if you noticed the tag "windows-10".
-
deuterium almost 4 years@JW0914 sorry for bad grammer of md. but it seems a general problem that CTRL+SHIFT+ENTER not work,notice a link i refered reports the problem happened on cmd.exe.\nit'strange that cmd do not work so,but mspaint do,and later when i try,cmd did too.
-
deuterium almost 4 yearsSeems the 2 way need to change system profile,i found some infomation about it,but none of them talked about which file i need to edit.
-
deuterium almost 4 yearsalso,i do not understand the 3 way,can u give it a more spcific discribtion,for I think it may be the final solution,thank you for your knolodge.
-
deuterium almost 4 yearsI don't know much about OS,or something like how a file is start,so these information may not enough fr me to realize.
-
JW0914 almost 4 years@deuterium I would recommend opening an issue on Windows Terminal's GitHub page, as there should be a single command that allows
wt
to open an Admin shell via cli, andwt
doesn't offer anything beyondnew-tab
,split-pane
, andfocus-tab
(the markdown request was for user23803838) -
JW0914 almost 4 years@WasifHasan Run... still offers this functionality, Windows 10 just removed the redundancy of the checkbox; in Run... press
SHIFT
+CTRL
+ENTER
/OK
-
JW0914 almost 4 years@deuterium For #2, issue any of those from Powershell, which is also the default shell of
wt
unless customized by the user, and it will launch an Admin terminal. For #3, you'd copy/paste that into%UserProfile%\Documents\Windows Powershell\Microsoft.PowerShell_profile.ps1
, as well as%UserProfile%\Documents\Windows Powershell\profile.ps1
if it exists, then reload the Powershell profile via& $profile
-
Seamus over 3 yearsCTRL+SHIFT+ENTER does work with 'PowerToys Run' utility to launch WT as admin. Interestingly CTRL+SHIFT+ENTER click also works on taskbar icon, no need to us a context menu.
-
Kenny83 over 3 yearsThis is pure gold! Now if only you could tell me how to pin the created shortcut to my taskbar, and have it so that clicking on that tile doesn't create another ungrouped tile after all others...well then you, sir, would become my god! LOL :P
-
Learning Mathematics over 3 yearsWhen I use this, it opens up a new Powershell instead of Windows Terminal. How to set it up so that I can run Powershell as admin within WT?
-
JW0914 over 3 years@LearningMathematics That I do not know - what you may want to do is open an issue on the Windows Terminal GitHub asking the same, as you'll likely get an answer faster from there.
-
Oneiros about 3 yearsAwesome, thank you. For those looking for the icon file: raw.githubusercontent.com/microsoft/terminal/main/res/…
-
Serhiy about 3 years@Kenny83 just drag'n'drop it on your taskbar.
-
deuterium almost 3 yearsthat is what i want,thank u.
-
Alexandre Daubricourt over 2 yearsThis is dope! I had to update the path to
$Shortcut.TargetPath = "$env:LOCALAPPDATA\Microsoft\WindowsApps\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\wt.exe"
though