Skip to main content
Every install adds an uninstall.exe to the install folder and an entry under Settings › Apps. This page explains what removing your app does, and how to offer your users to delete the data your app saved.

What the uninstaller removes

It removes what the installer added:
  • the files it installed
  • the shortcuts, the entry under Settings › Apps, and the Windows integration such as links, file types and PATH entries
  • the install folder, if nothing else is left in it
It keeps:
  • Files it didn’t install. If your app or the user created files in the install folder, such as logs or documents, they stay, and so does the folder.
  • Files that were changed after install. If a user edited a configuration file you shipped, the uninstaller keeps their version and notes it in the log.
  • User data elsewhere on the computer, unless you list it and the user asks to delete it.

Offer to delete user data

Apps usually save settings in a folder like %APPDATA%\Hello Notes. List those folders:
bach.toml
The removal window then shows an unticked Also delete my data box, with your description and the folder paths. The folders are only deleted if the user ticks it. Use single quotes around Windows paths, so TOML keeps the backslashes.

Which folders are allowed

To make sure an uninstaller can never delete someone’s documents, each entry must:
  • start with %APPDATA%, %LOCALAPPDATA% or %USERPROFILE%
  • name a folder of your own after that
Bach refuses, among others, whole user folders such as Documents or Desktop, anything inside .ssh, .aws or Microsoft, source code folders, other programs’ data such as browser profiles, and a whole company folder such as %APPDATA%\Google. A folder of your own inside a shared folder is fine, such as %USERPROFILE%\Documents\My Game. bach check warns if a folder doesn’t look like it belongs to your app. [uninstall] lists every rule.

Ask why people leave

bach.toml
The last page of the removal window shows a Tell us why link to this page. It must be an https address.

If the app is running

The uninstaller waits briefly, then stops with Hello Notes is still open. Close it, then try again. Nothing is removed in that case. If a file can’t be removed, for example because an antivirus program holds it, everything is put back and the app stays installed and working. If only a data folder can’t be deleted, the app is still removed and the last page names the folder.

Removing from a script

Add --delete-data to also delete the listed data folders. Start-Process -Wait is needed because uninstall.exe is a windows program: without it, your script wouldn’t wait for it. See Uninstaller options.

Run something before removal

If your app registers something that the uninstaller doesn’t know about, run your own cleanup program with a [[run]] step with when = "uninstall".

Why does uninstall.exe look unsigned?

The uninstaller is created on your user’s computer from your setup file, without the signature, because a signature only matches the exact file it was made for.

Test it

Install your app on a test computer, change a setting in it, then remove it with the box ticked and unticked. bach preview --uninstall shows the window without removing anything.