-
-
Notifications
You must be signed in to change notification settings - Fork 60
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.
- Role and entry point
- The Yes / No / Cancel dialog
- Removal sequence
- The self-deleting batch
- Registry and the uninstall entry
- Exception handling
- See also
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.Asteriskand shows a localized confirmation dialog (the interactive uninstall). -
With the silent argument — runs the removal without prompting. The registry uninstall entry stores a
QuietUninstallStringthat passes-sfor unattended removal (used bychoco uninstall,scoop uninstall, winget, etc.).
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) | — |

On Yes or No, Undo performs the following (Cancel aborts before any of it):
-
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. -
Restore the desktop — restores desktop-icon visibility and calls
RefreshDesktop()(Sucrose can hide desktop icons while a wallpaper runs). -
Delete the install folder — removes
UninstallPath=%LocalAppData%\Sucrose, preserving the currently runningUndoandRuntimefolders (those are removed later by the batch file). -
Optionally delete user data — on Yes, also deletes
UninstallDataPath=%AppData%\Sucrose. -
Remove shortcuts — deletes the Desktop and Start-Menu
<AppLongName>.lnkshortcuts. -
Remove the registry uninstall key — deletes the
HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\Sucrosesubkey (see below). -
Self-delete — generates and runs a batch file in
%TEMP%that finishes the job after Undo exits.
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.
flowchart TD
Start["Sucrose.Undo.exe"] --> Dlg{"Yes / No / Cancel"}
Dlg -->|Cancel| Abort["abort, no changes"]
Dlg -->|Yes or No| Kill["kill all Sucrose processes<br/>3 passes, 1s apart"]
Kill --> Desk["restore desktop icons<br/>+ RefreshDesktop()"]
Desk --> DelInstall["delete %LocalAppData%/Sucrose<br/>keep Undo + Runtime folders"]
DelInstall --> Data{"choice == Yes?"}
Data -->|yes| DelData["also delete %AppData%/Sucrose"]
Data -->|no| KeepData["keep user data"]
DelData --> Short["remove Desktop + Start-Menu shortcuts"]
KeepData --> Short
Short --> Reg["delete HKCU Uninstall key (Sucrose)"]
Reg --> Bat["spawn %TEMP%/del_<guid>.bat"]
Bat --> Self["batch: taskkill Undo,<br/>delete install/runtime/uninstall, self-delete"]
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.
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.
- Uninstalling Sucrose — the user-facing removal guide, including package-manager uninstall.
- Bundle / Installer Internals — how the installer creates the registry uninstall entry that Undo removes.
-
Data Locations — the install (
%LocalAppData%\Sucrose) and data (%AppData%\Sucrose) folders that Undo deletes. - Crash Reporting — why Undo opts out of the shared crash pipeline.
- Architecture Overview — Undo's place in the process roster.
Getting Started
- Installation
- System Requirements
- Quick Start
- Portal Interface Tour
- Updating Sucrose
- Uninstalling Sucrose
Wallpaper Types
Using Sucrose
- Managing Library
- Using Store
- Customizing Wallpaper
- Multi-Monitor
- Wallpaper Cycling
- Choosing Engines
- Performance Rules
- Theme, Tray & Startup
- Discord Rich Presence
Settings Reference
- Settings Overview
- Settings: General
- Settings: Personal
- Settings: Performance
- Settings: Wallpaper
- Settings: System
- Settings: Other
- Settings: All Keys
Creating Wallpapers
- Create Overview
- Create: Step By Step
- Create: Package Format
- Create: Customization Controls
- Create: JS Bridge
- Create: Audio API
- Create: System API
- Create: Property Listener & Filters
- Create: Web Architecture
- Create: Compatibility
- Create: Example Wallpapers
- Create: Sharing & Publishing
Engine Reference
- Engines Overview
- Engine: MpvPlayer
- Engine: VlcPlayer
- Engine: WebView
- Engine: CefSharp
- Engine: Nebula
- Engine: Vexana
- Engine: Xavier
- Engine: Aurora
- Engine Comparison
Automation & Command Line
Architecture & Internals
- Architecture Overview
- Lifecycle
- Commandog Dispatcher
- Single-Instance Mutexes
- IPC
- Backgroundog Service
- Crash Reporting
- Update Internals
- Property Service
- Undo Internals
Data, Files & Diagnostics
Building & Contributing
- Building From Source
- Repository Layout
- Shared Item Projects
- Code Conventions
- Preprocessor Symbols
- Publish Pipeline
- Bundle Installer Internals
- Extending Sucrose
- Contributing
- Translating with Localizer
- Localization Coverage
- Security Policy
- Privacy & Telemetry
Help & Support