SyncFolder — Desktop User Guide
Pre- and Post-Run Actions
Pre- and post-run actions let you attach automated steps to any SyncFolder task — before the sync begins and after it finishes. Use them to prepare the environment, chain tasks together in a sequence, or shut down the computer automatically once a long sync is complete.
Overview
Each task in SyncFolder can optionally carry two action hooks. They are configured in the Advanced Task Settings popup and run automatically every time the task executes — whether triggered manually, by a schedule, or by another task.
| Hook | When it runs | Available action types |
|---|---|---|
| Pre-run | Immediately before the sync starts | PowerShell script |
| Post-run | Immediately after the sync finishes (successfully) | PowerShell script · Execute another task · Shut down / Hibernate |
Post-run actions only fire when the task completes without errors. If the sync is aborted or encounters a critical error, post-run actions are skipped.
Pre-Run Action – PowerShell Script
The pre-run hook executes a single PowerShell command or script before any files are touched. This is the right place for tasks that need to set up the environment — mapping a network drive, stopping a service, or creating a lock file.
Configuring the script
- Open the task and click Advanced Task Settings to open the settings popup.
- Enable the Pre-run action toggle.
- Type your PowerShell command or script path in the text box that appears.
- Click Test to run the command immediately and inspect the result.
- The output panel appears below the text box. Close it with the × button when done.
Script examples
New-PSDrive -Name "Z" ` -PSProvider FileSystem ` -Root "\\server\share" ` -Persist
Stop-Service -Name "MyAppService" ` -Force # Wait until stopped Start-Sleep -Seconds 2
If the pre-run script exits with a non-zero exit code, SyncFolder treats it
as a failure and cancels the sync. Make sure your script ends cleanly — or
explicitly exit with exit 0 when errors are non-fatal.
Post-Run Actions
Post-run actions are configured in the Advanced Task Settings popup and execute after a successful sync. There are two primary post-run action types — a PowerShell script and Execute another task — and one additional option: Shut down / Hibernate. The shutdown/hibernate option always runs last, after any PowerShell script and after the chained task has been triggered. Each type is enabled independently.
PowerShell Script
Identical in setup to the pre-run script. Use this to undo any environment changes made by the pre-run action — removing a drive mapping, restarting a service, or writing a completion log entry.
Remove-PSDrive -Name "Z" -Force
Start-Service -Name "MyAppService" # Log completion Add-Content "C:\Logs\sync.log" ` "Sync completed $(Get-Date)"
Execute Another Task Optional
This action launches a second SyncFolder task automatically after the current one succeeds. Select the target task from the dropdown list, which shows all tasks currently defined in your SyncFolder configuration.
- Enable the Execute another task toggle in the post-run section.
- Select the desired task from the dropdown.
- The selected task will run only if the triggering task completed successfully.
- The chained task runs with its own settings, including any of its own pre- and post-run actions.
This feature makes it possible to implement parent–child–grandchild (rotation) logic: Task A triggers Task B on success, and Task B triggers Task C on success. Each task in the chain runs independently — with its own exclusion filters, sync mode, and action hooks.
Task chain example
D:\Work → NAS.Post-run: Execute Task B
Post-run: Execute Task C
Post-run: (none)
Avoid creating circular chains (Task A → Task B → Task A). SyncFolder does not currently detect cycles, so a circular chain will keep running until you manually stop it or the system is restarted.
Shut Down or Hibernate Optional
When a long-running sync is finished, SyncFolder can automatically shut down or hibernate the computer. This is useful for overnight backups where you want the machine to power off without manual intervention.
- Enable the Shut down / Hibernate after task toggle.
- Select the action: Shut down or Hibernate.
- Set the countdown interval (1–300 seconds). The default is 60 seconds.
- When the task finishes, SyncFolder shows a system notification with the countdown and an Abort button.
- If you do nothing, the action executes when the countdown reaches zero.
- Click Abort in the notification to cancel the shutdown or hibernate.
| Setting | Value / Range | Description |
|---|---|---|
| Action | Shut down · Hibernate | Which power action to perform |
| Interval | 1 – 300 seconds | Time between notification and action |
| User override | Always available | Abort button in the notification cancels the action |
Set the interval to at least 30 seconds so you have enough time to react to the notification, especially if SyncFolder is running in the background or on a secondary monitor.
The shut-down/hibernate action is executed after the post-run PowerShell script and after the chained task has been started (not completed). If you chain to another task, the computer may shut down before that task finishes.
Execution Order
When all post-run actions are enabled simultaneously, they execute in the following order:
- Pre-run PowerShell script runs.
- Task sync executes.
- Post-run PowerShell script runs (on success).
- Chained task is triggered (on success).
- Shutdown / hibernate countdown notification appears.
If the post-run PowerShell script fails (non-zero exit code), the chained task and the shutdown/hibernate action are both skipped. Ensure your cleanup scripts exit cleanly.
Tips and Best Practices
exit 0 for success and exit 1 (or any non-zero code)
to signal a real failure. Only fail the pre-run when you genuinely want to block the sync.
Last updated: May 3, 2026