microsoft / microsoft/winget-cli

Can not uninstall package due to Shell API (`SHEvaluateSystemCommandTemplate`) failure

Open
#5,648 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Command-Uninstall Issue-Bug
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Brief description of your issue

Original conversation in:

WinGet is having trouble before calling the uninstaller. I looked at the source code, and it seems like the error is coming from this Shell API call, which is WinGet sanity checking the UninstallString retrieved from Registry before calling the uninstaller

https://github.com/microsoft/winget-cli/blob/e0003534fd170d3b0fb5c6f446cd6db15e7ed71d/src/AppInstallerCLICore/Workflows/ShellExecuteInstallerHandler.cpp#L325

I was under the impression, as seen in the similar issue where this error was thrown: https://github.com/microsoft/winget-cli/issues/2171, that this call fails when the uninstaller mentioned in the Registry UninstallString (example: "C:\Program Files (x86)\OpenCPN\Uninstall 5.10.2-0+12e5712.exe /S") does not exist. However, this is failing here for some unknown reason because the uninstaller exists at the correct location on my machine, just that WinGet is never able to call it because of this Shell API failure.


As a temporary fix (because the issue is with uninstall), we can remove UpgradeBehavior: uninstallPrevious from the manifest, and let WinGet do a side-by-side install. The user will have multiple versions installed on their machine, and to remove the previous version, they'll have to use Apps&Features instead of WinGet, but this still feels like a better UX than just failing the upgrade outright.

Steps to reproduce
  1. winget install OpenCPN.OpenCPN --version 5.10.2
  2. winget uninstall OpenCPN.OpenCPN
Expected behavior

Uninstall is successful

Actual behavior

Does not uninstall, fails in the shell API validation. This affects upgrade scenario as this package installs side-by-side, and because of uninstall failure we cannot specify UpgradeBehavior: uninstallPrevious in the manifest

Environment
Windows Package Manager v1.11.430
    Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.26100.4652
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.26.430.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                        Enabled
BypassCertificatePinningForMicrosoftStore Enabled
InstallerHashOverride                     Enabled
LocalArchiveMalwareScanOverride           Disabled
ProxyCommandLineOptions                   Disabled
DefaultProxy                              Disabled

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/AppInstallerCLICore/Workflows/ShellExecuteInstallerHandler.cpp at the SHEvaluateSystemCommandTemplate call referenced in the issue. Reproduce with winget install OpenCPN.OpenCPN --version 5.10.2 followed by winget uninstall OpenCPN.OpenCPN, then trace why validation rejects the existing UninstallString. Done means the package uninstalls successfully through WinGet.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.