Launching wt.exe as admin fails #4384

Closed
opened 2026-01-30 23:45:38 +00:00 by claunia · 9 comments
Owner

Originally created by @wigster on GitHub (Oct 10, 2019).

Environment

Windows build number: 18363.418
Windows Terminal version (if applicable): 0.5.2762.0

Steps to reproduce

  • Open Start Menu
  • Type wt to get the shortcut to WinTerm
  • Click Run as Administrator

Expected behavior

WinTerm should run as administrator

Actual behavior

There is an error and a box appears with:

[Window Title]
C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\wt.exe

[Content]
C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\wt.exe

The file cannot be accessed by the system.


[OK]

Comment: Running as admin from the Windows Terminal (Preview) shrortcut icon in the start menu works fine.

Originally created by @wigster on GitHub (Oct 10, 2019). # Environment ``` Windows build number: 18363.418 Windows Terminal version (if applicable): 0.5.2762.0 ``` # Steps to reproduce - Open Start Menu - Type wt to get the shortcut to WinTerm - Click Run as Administrator # Expected behavior WinTerm should run as administrator # Actual behavior There is an error and a box appears with: ``` [Window Title] C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\wt.exe [Content] C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\wt.exe The file cannot be accessed by the system. [OK] ``` Comment: Running as admin from the Windows Terminal (Preview) shrortcut icon in the start menu works fine.
claunia added the Resolution-ExternalNeeds-Tag-Fix labels 2026-01-30 23:45:38 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Oct 10, 2019):

This is an OS bug that we're pursuing internally. Thanks for reporting!

@DHowett-MSFT commented on GitHub (Oct 10, 2019): This is an OS bug that we're pursuing internally. Thanks for reporting!
Author
Owner

@Serhiy-Shekhovtsov commented on GitHub (Jan 20, 2020):

@DHowett-MSFT is there any bug tracking system where we can watch/subscribe for updates on this issue?

@Serhiy-Shekhovtsov commented on GitHub (Jan 20, 2020): @DHowett-MSFT is there any bug tracking system where we can watch/subscribe for updates on this issue?
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 28, 2020):

@Serhiy-Shekhovtsov just this one. Sorry!

@DHowett-MSFT commented on GitHub (Jan 28, 2020): @Serhiy-Shekhovtsov just this one. Sorry!
Author
Owner

@playmer commented on GitHub (Jan 29, 2020):

Sorry to bug, but I just wanted to check, could we not provide a secondary launcher exe that can be launched in Admin and launches wt.exe for us? The most simple version of this seems to work with Admin just fine.

This should probably only really be considered if the external issue is going to take a long time to resolve, but it's a decent workaround in the meantime. (And even if Windows Terminal doesn't provide it, others might want to know you can do it.)

@playmer commented on GitHub (Jan 29, 2020): Sorry to bug, but I just wanted to check, could we not provide a secondary launcher exe that can be launched in Admin and launches wt.exe for us? The most simple version of this seems to work with Admin just fine. This should probably only really be considered if the external issue is going to take a long time to resolve, but it's a decent workaround in the meantime. (And even if Windows Terminal doesn't provide it, others might want to know you can do it.)
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 29, 2020):

Unfortunately, unless we ship it as a sidecar (like, an executable that you have to download and install separately), it's going to be subject to the same issues as wt.exe itself. Things that live in appx/msix packages are simply troublesome in this regard.

@DHowett-MSFT commented on GitHub (Jan 29, 2020): Unfortunately, unless we ship it as a sidecar (like, an executable that you have to download and install separately), it's going to be subject to the same issues as `wt.exe` itself. Things that live in appx/msix packages are simply _troublesome_ in this regard.
Author
Owner

@playmer commented on GitHub (Jan 30, 2020):

I see, thanks!

@playmer commented on GitHub (Jan 30, 2020): I see, thanks!
Author
Owner

@Beej126 commented on GitHub (Mar 8, 2020):

in the interim, use a 3rd party launcher, e.g. nircmd

nircmd.exe elevate "shell:appsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App"

confirm metro app path via powershell:

Get-appxpackage *WindowsTerminal*
@Beej126 commented on GitHub (Mar 8, 2020): in the interim, use a 3rd party launcher, e.g. [nircmd](https://www.nirsoft.net/utils/nircmd.html) ``` nircmd.exe elevate "shell:appsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App" ``` confirm metro app path via powershell: ``` Get-appxpackage *WindowsTerminal* ```
Author
Owner

@gamgamstylep commented on GitHub (Mar 31, 2020):

This works without additional programs

so you can make a shortcut

Source of elevate see: https://stackoverflow.com/a/12264592/1016343

elevate_windows_terminal.bat

::::::::::::::::::::::::::::::::::::::::::::
:: Elevate.cmd - Version 4
:: Automatically check & get admin rights
:: see "https://stackoverflow.com/a/12264592/1016343" for description
::::::::::::::::::::::::::::::::::::::::::::
 @echo off
 CLS
 ECHO.
 ECHO =============================
 ECHO Running Admin shell
 ECHO =============================

:init
 setlocal DisableDelayedExpansion
 set cmdInvoke=1
 set winSysFolder=System32
 set "batchPath=%~0"
 for %%k in (%0) do set batchName=%%~nk
 set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
 setlocal EnableDelayedExpansion

:checkPrivileges
  NET FILE 1>NUL 2>NUL
  if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
  if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
  ECHO.
  ECHO **************************************
  ECHO Invoking UAC for Privilege Escalation
  ECHO **************************************

  ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
  ECHO args = "ELEV " >> "%vbsGetPrivileges%"
  ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
  ECHO args = args ^& strArg ^& " "  >> "%vbsGetPrivileges%"
  ECHO Next >> "%vbsGetPrivileges%"

  if '%cmdInvoke%'=='1' goto InvokeCmd 

  ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  goto ExecElevation

:InvokeCmd
  ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
  ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"

:ExecElevation
 "%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
 exit /B

:gotPrivileges
 setlocal & cd /d %~dp0
 if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul  &  shift /1)

 ::::::::::::::::::::::::::::
 ::START
 ::::::::::::::::::::::::::::
 REM Run shell as admin (example) - put here code as you like
 start D:\bat\windows_terminal\windows_terminal.bat
 exit

plus

windows_terminal.bat

start C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\wt.exe
exit

Change username

@gamgamstylep commented on GitHub (Mar 31, 2020): # **This works without additional programs** so you can make a shortcut Source of elevate see: <https://stackoverflow.com/a/12264592/1016343> # elevate_windows_terminal.bat ```powershell :::::::::::::::::::::::::::::::::::::::::::: :: Elevate.cmd - Version 4 :: Automatically check & get admin rights :: see "https://stackoverflow.com/a/12264592/1016343" for description :::::::::::::::::::::::::::::::::::::::::::: @echo off CLS ECHO. ECHO ============================= ECHO Running Admin shell ECHO ============================= :init setlocal DisableDelayedExpansion set cmdInvoke=1 set winSysFolder=System32 set "batchPath=%~0" for %%k in (%0) do set batchName=%%~nk set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs" setlocal EnableDelayedExpansion :checkPrivileges NET FILE 1>NUL 2>NUL if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) :getPrivileges if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges) ECHO. ECHO ************************************** ECHO Invoking UAC for Privilege Escalation ECHO ************************************** ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%" ECHO args = "ELEV " >> "%vbsGetPrivileges%" ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%" ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%" ECHO Next >> "%vbsGetPrivileges%" if '%cmdInvoke%'=='1' goto InvokeCmd ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%" goto ExecElevation :InvokeCmd ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%" ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%" :ExecElevation "%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %* exit /B :gotPrivileges setlocal & cd /d %~dp0 if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) :::::::::::::::::::::::::::: ::START :::::::::::::::::::::::::::: REM Run shell as admin (example) - put here code as you like start D:\bat\windows_terminal\windows_terminal.bat exit ``` **plus** # windows_terminal.bat ```powershell start C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\wt.exe exit ``` Change username
Author
Owner

@nisargjhaveri commented on GitHub (May 14, 2020):

If anyone is still looking for a simpler work-around, here is one.

You can create a shortcut with location pointing to the following command.

  1. Right click -> New -> Shortcut
  2. Type in C:\Windows\System32\cmd.exe /c start /b %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wt.exe for the location
  3. Give whatever name you want to give, finish.
  4. Right click on the newly created shortcut -> Properties -> Advanced -> Run as administrator

This shortcut will now open WT in admin mode. You can use this shortcut file from non-privileged cmd/wsl also to open a new Terminal window in admin mode.

@nisargjhaveri commented on GitHub (May 14, 2020): If anyone is still looking for a simpler work-around, here is one. You can create a shortcut with location pointing to the following command. 1. Right click -> New -> Shortcut 1. Type in `C:\Windows\System32\cmd.exe /c start /b %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wt.exe` for the location 1. Give whatever name you want to give, finish. 1. Right click on the newly created shortcut -> Properties -> Advanced -> Run as administrator This shortcut will now open WT in admin mode. You can use this shortcut file from non-privileged cmd/wsl also to open a new Terminal window in admin mode.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4384