I have a WiX setup which has
<MajorUpgrade Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
If an error during the upgrade occurs, the setup rolls back and restores the previously installed version. However, a scheduled task created via a custom action is lost and never restored.
The custom actions I'm using for creation/removal/rollback of the task are:
<!-- task scheduling -->
<CustomAction Id="CreateScheduledTask" Return="check" Directory="SystemFolder"
ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Create /RU "[TASK_DOMAIN]\[TASK_USERNAME]" /RP [TASK_PASSWORD] /SC DAILY /TN "Maintenance" /TR "[\\]"[SERVICELOCATION]Maintenance.exe[\\]"" /ST [TASK_TIME]"
Execute= "deferred"/>
<!-- rollback in case something went wrong -->
<CustomAction Id="CreateScheduledTask_Rollback" Execute="rollback" Return="ignore" Directory="SystemFolder" ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Delete /TN "Maintenance" /F" />
<!-- removal of task -->
<CustomAction Id="RemoveScheduledTask" Return="ignore" Directory="SystemFolder" ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Delete /TN "Maintenance" /F" Execute= "immediate"/>
which are queued as
<InstallExecuteSequence>
<Custom Action="CreateScheduledTask_Rollback" Before="CreateScheduledTask"></Custom>
<Custom Action="CreateScheduledTask" Before="InstallFinalize"></Custom>
<Custom Action="RemoveScheduledTask" Before="RemoveFiles">
<![CDATA[(REMOVE="ALL")]]>
</Custom>
</InstallExecuteSequence>
The CreateScheduledTask
-action had a condition of NOT Installed
which I removed for testing purposes.
Can anyone tell me, what I'd need to do, in order to have the task re-created when the upgrade setup rolls back? P.S.: I do not have access to the domain, username or password the task was originally created with.