-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WindowsTerminal fails to launch elevate=true profiles on new install; elevate-shim does not set dllpath #14501
Comments
Process Monitor Trace shows the shim launching an elevated WindowsTerminal.exe, however -- note the paths used to resolve DLLs is different than the unelevated process (and fails). |
I took dump snapshots (via Task Manager) of WindowsTerminal.exe of unelevated (after initial launch) and the elevated process (while the initial error dialog is on screen). Notable, the DllPath is different between the two. Unelevated:
Elevated:
|
Finally; you can verify this on a working system by attaching a debugger to WindowsTerminal.exe and inspecting the loaded modules for an unelevated vs elevated process. Note the image path is different. Edit: the dll versions are different too, that's interesting from a bug/support perspective. unelevated:
elevated:
|
👍🏼 great collection of details |
This is wild, and a great collection of details. I'm not entirely sure how we go about actually fixing this. Kinda seems to me like something that the package infrastructure should have taken care of for us, but I can't be sure. We'll need to follow up with some folks and investigate. I reckon this is gonna come to something that we could theoretically work around, but we should make sure the rest of the platform team is aware of this. (@DHowett putting this in your inbox for after vacation - who owns the MSIX bits these days that we should follow up with?) |
I went down quite the rabbit hole exploring how a new process is created with ShellExecuteEx runas. It was also a good excuse to learn more about Time Travel Debug and store apps. From what I can gather, the ShellExecuteEx call from elevate-shim eventually fires off some RPC COM calls via Explorer.exe to launch the new process However, launching Terminal via the start menu (elevated or not) seems to follow a different process that is aware of the store app manifest. I can see the AppInfo service (svchost.exe) reading the app manifest file here: |
It looks like there is a viable path with minimal changes (still uses the shim and ShellExecute); it would require some state to determine if the original process was launched as a store app vs some other means (e.g. developer mode). This state would be passed along to the elevate shim to make a decision to use Relevant: PowerToys knows how to launch processes elevated using string command = "shell:AppsFolder\\" + UniqueIdentifier;
command = Environment.ExpandEnvironmentVariables(command.Trim());
var info = ShellCommand.SetProcessStartInfo(command, verb: "runas");
info.UseShellExecute = true;
info.Arguments = queryArguments;
Process.Start(info);
return true; |
Fixes microsoft#14501 This uses `shell:AppsFolder` to launch elevated instances of the app via `ShellExecuteEx` and `runas` in elevate-shim.exe. The app to launch is discovered via the `GetCurrentApplicationUserModelId` API. e.g. `shell:AppsFolder\WindowsTerminalDev_8wekyb3d8bbwe!App` This will fallback to launching `WindowsTerminal.exe` if it fails to discover the app user model id to launch. This also fixes an innocuous bug in elevate-shim where the first argument of WinMain was lost (e.g. `new-tab`).
This uses `shell:AppsFolder` to launch elevated instances of the app via `ShellExecuteEx` and `runas` in elevate-shim.exe. The app to launch is discovered via the `GetCurrentApplicationUserModelId` API. e.g. `shell:AppsFolder\WindowsTerminalDev_8wekyb3d8bbwe!App` This will fallback to launching `WindowsTerminal.exe` if it fails to discover the app user model id to launch. This also fixes a bug in elevate-shim where the first argument of WinMain was lost (e.g. `new-tab`). Curiously, `AppLogic::RunAsUwp()` is never called and `AppLogic::IsUwp()` is always false when running debug builds locally (e.g. WindowsTerminalDev). It's not clear if this is an artifact of development packages or something else. ## Validation Steps Performed Various manual debug/execution scenarios. Verified the fallback path by running the unbundled app by extracting the `CascadiaPackage_0.0.1.0_x64.msix` from the 'drop' build artifact. Fixes #14501
🎉This issue was addressed in #14637, which has now been successfully released as Handy links: |
This uses `shell:AppsFolder` to launch elevated instances of the app via `ShellExecuteEx` and `runas` in elevate-shim.exe. The app to launch is discovered via the `GetCurrentApplicationUserModelId` API. e.g. `shell:AppsFolder\WindowsTerminalDev_8wekyb3d8bbwe!App` This will fallback to launching `WindowsTerminal.exe` if it fails to discover the app user model id to launch. This also fixes a bug in elevate-shim where the first argument of WinMain was lost (e.g. `new-tab`). Curiously, `AppLogic::RunAsUwp()` is never called and `AppLogic::IsUwp()` is always false when running debug builds locally (e.g. WindowsTerminalDev). It's not clear if this is an artifact of development packages or something else. ## Validation Steps Performed Various manual debug/execution scenarios. Verified the fallback path by running the unbundled app by extracting the `CascadiaPackage_0.0.1.0_x64.msix` from the 'drop' build artifact. Fixes #14501
This uses `shell:AppsFolder` to launch elevated instances of the app via `ShellExecuteEx` and `runas` in elevate-shim.exe. The app to launch is discovered via the `GetCurrentApplicationUserModelId` API. e.g. `shell:AppsFolder\WindowsTerminalDev_8wekyb3d8bbwe!App` This will fallback to launching `WindowsTerminal.exe` if it fails to discover the app user model id to launch. This also fixes a bug in elevate-shim where the first argument of WinMain was lost (e.g. `new-tab`). Curiously, `AppLogic::RunAsUwp()` is never called and `AppLogic::IsUwp()` is always false when running debug builds locally (e.g. WindowsTerminalDev). It's not clear if this is an artifact of development packages or something else. ## Validation Steps Performed Various manual debug/execution scenarios. Verified the fallback path by running the unbundled app by extracting the `CascadiaPackage_0.0.1.0_x64.msix` from the 'drop' build artifact. Fixes #14501 (cherry picked from commit eab1c23) Service-Card-Id: 87690177 Service-Version: 1.16
🎉This issue was addressed in #14637, which has now been successfully released as Handy links: |
1 similar comment
🎉This issue was addressed in #14637, which has now been successfully released as Handy links: |
To close the loop on this, a colleague helped dig into why this regressed recently in the Terminal:
There's also now MSFT:43119564 tracking making sure that this is fixed in the OS too, so no one else runs into this. Big s/o to @johnstep for doing the hard work here, and @jboelter for fixing this before we rolled it out to the whole of the Terminal install base. Thanks again! |
Windows Terminal version
1.15.2875.0
Windows build number
10.0.22621.819
Other Software
N/A - brand new system setup
Steps to reproduce
This should repro on a brand new Windows 11 installation as long as you do not have vcruntime140.dll in your default system %PATH%.
Command Prompt
profile and setting theelevate = true
flagCommand Prompt (elevated)
profile (or whatever you named it)Will provide additional details in the comments. I've got procmon traces, dump snapshots and a method to observe this w/o the failure. Issue seems to be related to ShellExecuteExW in elevate-shim not setting the DllPath in the elevated process.
Expected Behavior
New Windows Terminal window launches w/ elevated cmd.exe
Actual Behavior
WindowsTerminal.exe fails to launch w/ "not found" errors for msvcp140.dll, vcruntime140.dll, vcruntime140_1.dll
The text was updated successfully, but these errors were encountered: