Creating a scheduled task
Adding a scheduled task to the system allows us to perform some action, such as running an executable, at a specific time each hour, day, or month. It might be to clean up old log files, check for software updates, or process a batch file. With WiX, we can add a scheduled task at the time of installation and remove it when our software is uninstalled.
In this recipe, we'll add a simple task that calls the calculator program once per day. We'll also include markup to remove the task if the installation should fail, or if the user decides to uninstall our software.
Getting ready
To prepare for this recipe, perform the following steps:
- Create a new setup project and call it
ScheduledTaskInstaller
. - For an installer to succeed, it must install at least one file. Add a text file called
Sample.txt
to the project and then add aComponent
andFile
element to it:<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"...