Skip to content

Undo Internals

Taiizor edited this page Jun 5, 2026 · 4 revisions

Undo Internals

Despite the "rollback" name, the shipped Sucrose.Undo.exe is effectively Sucrose's uninstaller / full-removal tool. It is the process Windows runs when you remove Sucrose from Apps & Features, and it is responsible for terminating every Sucrose process, deleting the install and (optionally) the user-data folders, removing shortcuts and the registry uninstall key, restoring hidden desktop icons, and finally deleting itself with a self-cleaning batch file. This page documents that removal flow for developers and administrators. For the user-facing steps, see Uninstalling Sucrose.

Contents

Role and entry point

Sucrose.Undo.exe is a WPF process registered as the uninstaller for Sucrose. Unlike most Sucrose apps, it does not single-instance-gate through Instance.Basic, and it does not route its own crashes through the Watchdog (see Exception handling).

Its behavior depends on whether it is launched with arguments:

  • No arguments — plays SystemSounds.Asterisk and shows a localized confirmation dialog (the interactive uninstall).
  • With the silent argument — runs the removal without prompting. The registry uninstall entry stores a QuietUninstallString that passes -s for unattended removal (used by choco uninstall, scoop uninstall, winget, etc.).

The Yes / No / Cancel dialog

When launched interactively, Undo shows a localized Yes / No / Cancel dialog (resource keys Undo.QuestionTitle, Undo.QuestionMessage, Undo.QuestionDescription). The choice controls whether user data is kept:

Choice Removes app? Removes user data?
Yes Yes Yes — also deletes UninstallDataPath = %AppData%\Sucrose
No Yes No — keeps %AppData%\Sucrose
Cancel No (abort)

📷 Screenshot needed: the Sucrose Undo Yes/No/Cancel uninstall confirmation dialog.

Removal sequence

On Yes or No, Undo performs the following (Cancel aborts before any of it):

  1. Terminate all Sucrose processes — kills every process whose name contains Sucrose, in 3 passes spaced 1 second apart (Delay = 1000), so freshly-spawned helpers (Commandog, etc.) are also caught.
  2. Restore the desktop — restores desktop-icon visibility and calls RefreshDesktop() (Sucrose can hide desktop icons while a wallpaper runs).
  3. Delete the install folder — removes UninstallPath = %LocalAppData%\Sucrose, preserving the currently running Undo and Runtime folders (those are removed later by the batch file).
  4. Optionally delete user data — on Yes, also deletes UninstallDataPath = %AppData%\Sucrose.
  5. Remove shortcuts — deletes the Desktop and Start-Menu <AppLongName>.lnk shortcuts.
  6. Remove the registry uninstall key — deletes the HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\Sucrose subkey (see below).
  7. Self-delete — generates and runs a batch file in %TEMP% that finishes the job after Undo exits.

The self-deleting batch

The install folder cannot fully delete the running Undo.exe and the private Sucrose.Runtime while they are in use, so Undo writes a one-shot batch file to the temp folder and launches it:

%TEMP%\del_<guid>.bat

The batch:

taskkill /F /IM Sucrose.Undo.exe
timeout /t 3
rd /s /q "<install path>"
rd /s /q "<runtime path>"
rd /s /q "<uninstall path>"
del "%~f0"

In words: taskkill the Undo process itself, wait 3 seconds for handles to release, recursively delete the remaining install / runtime / uninstall paths, then delete the batch file. This is how the last on-disk traces are removed after the WPF process is already gone.

🖼️ Diagram needed: Undo removal sequence — confirm dialog → kill all Sucrose processes (3 passes) → restore desktop → delete install (keep Undo/Runtime) → optional data delete → remove shortcuts + registry key → spawn del_.bat → self-delete.

Registry and the uninstall entry

Sucrose installs per-user (no admin), so its uninstall entry lives under the current-user hive:

HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\Sucrose

This is the entry that makes Sucrose appear in Apps & Features; its QuietUninstallString uses the -s switch for silent removal. Undo deletes this key as part of the removal sequence. The key is created by the installer, not by Undo — see Bundle / Installer Internals.

Exception handling

Undo handles its own unhandled exceptions with a plain WPF MessageBox — it deliberately does not route through the Crash Reporting Watchdog pipeline. This is intentional: by the time Undo runs, it may already have terminated the Watchdog and Commandog processes that the crash pipeline depends on, so a self-contained dialog is the only reliable feedback.

See also

Home

Getting Started

Wallpaper Types

Using Sucrose

Settings Reference

Creating Wallpapers

Engine Reference

Automation & Command Line

Architecture & Internals

Data, Files & Diagnostics

Building & Contributing

Help & Support

Clone this wiki locally