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
PATHentries - the install folder, if nothing else is left in it
- 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
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
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
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
--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.