Skip to content

Setup: Fix modern uninstaller wizard and legacy uninstall launch behavior#2980

Open
NotEnsoul wants to merge 3 commits into
winsiderss:masterfrom
NotEnsoul:fix-uninstall-wizard-2977-2979
Open

Setup: Fix modern uninstaller wizard and legacy uninstall launch behavior#2980
NotEnsoul wants to merge 3 commits into
winsiderss:masterfrom
NotEnsoul:fix-uninstall-wizard-2977-2979

Conversation

@NotEnsoul

Copy link
Copy Markdown
Contributor

Description

This PR resolves two related uninstallation issues in the CustomSetupTool setup and uninstall dialog flow:

  1. Modern Wizard Uninstaller Support (Fixes Cannot uninstall in the latest canary version #2977):
    • Previously, running CustomSetupTool with -uninstall launched the property sheet wizard (SetupShowWizard) but defaulted to the installation layout and pages, rendering interactive uninstallation broken.
    • We updated SetupShowWizard to conditionally load a new IDD_UNINSTALL confirmation page and register SetupUninstallPageDlgProc when uninstallation mode is detected.
    • Wired UAC restart elevation and dynamic text/control adaptations inside SetupInstallPageDlgProc, SetupCompletedPageDlgProc, and SetupErrorPageDlgProc to display correct descriptions and hide the "Start application" checkbox on uninstallation.
    • Correctly integrates with the custom dark-mode button drawing by setting Button_SetElevationRequiredState on the first page, drawing the stock UAC shield icon.

  1. Legacy Uninstall Prompt Behavior (Fixes Legacy uninstall guide behavior mismatch #2979):
    • Under the legacy SetupShowDialog (TaskDialog) implementation, selecting "Remove application settings" and clicking "Cancel" would launch System Informer upon exit. This occurred because the verification checkbox state was evaluated without checking if the installation completed successfully.
    • Introduced a SetupCompleted flag inside Flags union in the PH_SETUP_CONTEXT structure, tracking successful completions in both the installer and uninstaller threads.
    • Corrected the application execution condition inside SetupShowDialog to only run the application if setup succeeded (SetupCompleted == TRUE and SetupMode == SetupCommandInstall).

  1. And lastly:
    • Added suppression of error dialogs when UAC elevation is cancelled by the user (STATUS_CANCELLED and NTSTATUS_FROM_WIN32(ERROR_CANCELLED)), preventing unexpected error alerts.

@NotEnsoul NotEnsoul requested a review from dmex as a code owner July 7, 2026 11:55
@NotEnsoul

Copy link
Copy Markdown
Contributor Author

i also added a uninstall welcome page because it felt weird leaving it like that

@dmex dmex self-assigned this Jul 7, 2026
@dmex dmex added the enhancement New feature or request label Jul 7, 2026
dmex added a commit that referenced this pull request Jul 7, 2026
Co-Authored-By: NotEnsoul <285614582+NotEnsoul@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes uninstall behavior in CustomSetupTool for both the modern wizard and the legacy TaskDialog flow, ensuring the correct UI/pages are shown for uninstallation and that the app is not incorrectly launched after a cancelled/failed uninstall. It also improves UAC-cancel handling to avoid spurious error dialogs.

Changes:

  • Adds dedicated uninstall wizard pages/flow and wires uninstall progress/completion/error UI states.
  • Introduces a SetupCompleted flag to gate “start application” behavior in the legacy TaskDialog flow.
  • Suppresses error reporting when elevation is cancelled and updates dialog resources/IDs for the new uninstall UI.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tools/CustomSetupTool/wizard.c Adds uninstall wizard page/proc, updates wizard routing/captions, and adjusts uninstall-specific UI text and error handling.
tools/CustomSetupTool/uninstall.c Sets SetupCompleted on successful uninstall and posts uninstall-final messages.
tools/CustomSetupTool/setup.h Extends PH_SETUP_CONTEXT flags with SetupCompleted and declares the new uninstall page proc.
tools/CustomSetupTool/resource.rc Adds IDD_UNINSTALL_WELCOME, adds uninstall “remove settings” checkbox, and fixes subtitle control IDs on completed/error pages.
tools/CustomSetupTool/resource.h Adds new dialog/control IDs for uninstall welcome and remove-settings checkbox.
tools/CustomSetupTool/main.c Prevents launching the application unless install completed successfully in legacy TaskDialog flow.
tools/CustomSetupTool/install.c Sets SetupCompleted on successful install completion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/CustomSetupTool/wizard.c
Comment on lines +1198 to +1210
switch (header->code)
{
case PSN_SETACTIVE:
SetupSetWizardButtons(WindowHandle, PSWIZB_BACK | PSWIZB_NEXT, TRUE, TRUE, FALSE, TRUE);
SetupSetWizardButtonText(context->ParentWindowHandle, IDC_PROPSHEET_NEXT, L"Uninstall");
if (!PhGetOwnTokenAttributes().Elevated)
{
Button_SetElevationRequiredState(GetDlgItem(context->ParentWindowHandle, IDC_PROPSHEET_NEXT), TRUE);
}
break;
case PSN_QUERYCANCEL:
return !SetupCancelWizard(WindowHandle, context);
case PSN_WIZNEXT:
PhDereferenceObject(applicationFileName);
}
}
SetWindowLongPtr(WindowHandle, DWLP_MSGRESULT, TRUE);
Comment on lines +116 to 118
Context->SetupCompleted = TRUE;
PostMessage(Context->DialogHandle, SETUP_SHOWUNINSTALLFINAL, 0, 0);
return STATUS_SUCCESS;
Comment thread tools/CustomSetupTool/resource.h
Comment on lines +1393 to 1396
else if (status != STATUS_CANCELLED && status != NTSTATUS_FROM_WIN32(ERROR_CANCELLED))
{
PhShowStatus(NULL, L"Unable to restart the application.", status, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot uninstall in the latest canary version Legacy uninstall guide behavior mismatch

3 participants