microsoft / microsoft/winget-cli
ShellExecuteEx that invokes a handler that uses DelegateExecute always fails
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.4k
- Forks
- 1.8k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 15
Description
Relevant area(s)
WinGet CLI
Relevant command(s)
winget install
Brief description of your issue
AICLI_LOG(CLI, Info, << "Starting: '" << filePath.u8string() << "' with arguments '" << args << '\'');
SHELLEXECUTEINFOW execInfo = { 0 };
execInfo.cbSize = sizeof(execInfo);
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
execInfo.lpFile = filePath.c_str();
std::wstring argsUtf16 = Utility::ConvertToUTF16(args);
execInfo.lpParameters = argsUtf16.c_str();
execInfo.nShow = show;
// This installer must be run elevated, but we are not currently.
// Have ShellExecute elevate the installer since it won't do so itself.
if (useRunAs)
{
execInfo.lpVerb = L"runas";
}
THROW_LAST_ERROR_IF(!ShellExecuteExW(&execInfo) || !execInfo.hProcess);
wil::unique_process_handle process{ execInfo.hProcess };
Windows shell verb registration allows a developer to intercept launching an executable and instead delegate the "Open" or "Runas" action to a COM object. Such delegation results in hProcess being NULL and results in error.
I'm not sure whether the delegation was purposefuly handled this way, but it feels like the delegation process should be responsible for reporting the feedback.
Steps to reproduce
Register any COM object and shell verb registration for "runas".
Then run:
winget install --id Microsoft.PowerShell --source winget
Expected behavior
It is my opinion, but I would not expect error message.
It's worth noting that we will be unable to wait till process finish, so we cannot tell if installation was successful.
Actual behavior
Error appearing.
PS D:\Users\admin> winget install --id Microsoft.PowerShell --source winget
Found an existing package already installed. Trying to upgrade the installed package...
Found PowerShell [Microsoft.PowerShell] Version 7.6.0.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.6.0/PowerShell-7.6.0-win-x64.msi
██████████████████████████████ 109 MB / 109 MB
Successfully verified installer hash
Starting package install...
An unexpected error occurred while executing the command:
0x8007029c : An assertion failure has occurred.
Environment
PS D:\Users\admin> winget --info
Windows Package Manager v1.28.220
Copyright (c) Microsoft Corporation. All rights reserved.
Windows: Windows.Desktop v10.0.26200.8037
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.28.220.0
Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User) %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User) %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root C:\Program Files\WinGet\Packages
Portable Package Root (x86) C:\Program Files (x86)\WinGet\Packages
Installer Downloads %USERPROFILE%\Downloads
Configuration Modules %LOCALAPPDATA%\Microsoft\WinGet\Configuration\Modules
Links
---------------------------------------------------------------------------
Privacy Statement https://aka.ms/winget-privacy
License Agreement https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale
Admin Setting State
--------------------------------------------------
LocalManifestFiles Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride Disabled
LocalArchiveMalwareScanOverride Disabled
ProxyCommandLineOptions Disabled
DefaultProxy Disabled
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the winget install path and the shown ShellExecuteExW call, then reproduce the runas case with a DelegateExecute handler. Trace how a delegated launch leaves hProcess null and how the current error path reports it. Done means delegated launches no longer produce the assertion error while accounting for the inability to wait for installation completion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100