Skip to main content
With automatic updates, people who installed your app get new versions without downloading anything. This page shows how to turn them on, what they do on the user’s computer, and how your app can check for updates itself. Turn this on before your first public release if you can. A copy installed without [updates] can’t update itself later; its user has to run a newer setup file once.

1. Say where updates come from

If your code is on GitHub and the repository is public:
bach.toml
For any other https host:
bach.toml
feed is the address of the update feed. download_url is where the setup file will be, with {file} replaced by its name. Where to host updates walks through both. Your version must be numbers with dots, such as 1.2.0, so Bach can compare versions.

2. Build and publish

Next to the setup file you now get latest.json:
latest.json
Upload both files. For every new version, upload the new setup file and replace latest.json. If you sign the setup file after building, write the feed again with bach feed, because signing changes the file.

What the user sees

The install window has an extra box, Automatic updates, ticked. If the user leaves it ticked, setup creates a Windows scheduled task for their account that checks for updates every four hours, and soon after the computer is turned on again if a check was missed. It runs hidden and needs no administrator rights. Each check:
  1. reads the feed
  2. downloads a newer version, if there is one
  3. installs it, but only if your app isn’t running; otherwise it waits for a later check
Your app is never closed while someone is using it. Unticking the box during a later update removes the task. So does uninstalling.

Change the default

bach.toml
Apps that install for every user can’t update in the background, because a normal user can’t write to Program Files. Leave auto out for them.

Check for updates from your app

The installed uninstall.exe also handles updates. Your app can run it: --json prints one line with app, current, latest, available, downloaded, notes and size. uninstall.exe is in your app’s install folder, next to your program.

Update when the user quits

A common pattern:
  1. When your app starts, run uninstall.exe --download-update in the background.
  2. When the user quits, or clicks “Restart to update”, start this and exit:
--wait-for waits for your app to close, and --launch starts it again after updating. The download already happened while the app was open, so the update itself takes a moment. To try the commands in PowerShell, use Start-Process, which waits and gives you the exit code:

Interrupted updates

  • If the download stops, it continues where it left off next time.
  • If a file is held for a moment, for example by a virus scanner right after your app closes, --apply-update tries three times, then keeps the download for later.
  • If the computer shuts down during an update, the next check or setup puts the old files back first.

When something goes wrong

Every update run writes %TEMP%\<app id>-update.log. Why aren’t automatic updates working? goes through the usual causes.