Skip to main content
You can have the launcher ask for elevated privileges only when an update is needed and the install folder is protected, such as C:\Program Files on Windows.
This also works on macOS, but we don’t recommend running game updates as the root user on a Mac.

Check the repository for updates

A repositoryCheck task decides whether the repository needs installing or updating, and routes the workflow. Here both cases go to the writable check:

Check whether the folder is writable

A directoryIsWritable task checks whether the launcher can write to the install folder with its current permissions. Unless the player runs it as administrator, the launcher runs as a regular user.
If the folder is writable, such as c:\Users\Username\Games\, the launcher updates normally. If it isn’t, such as c:\Program Files (x86)\Games\, the workflow asks for administrator rights.

Run the update elevated

A workflowRun task with "elevated": true runs a task with administrator rights. start names the task to run in the existing workflow.
When this task runs, Windows shows a User Account Control prompt asking the player to let the launcher run as administrator. For more about workflowRun, see Tasks.

Full example

This workflow uses a unified progress bar for two repositories and only elevates if an update is needed. The repair task, which runs when the player clicks Repair, also elevates if needed.
workflow.json