You need another rollback custom action for RemoveScheduledTask
that does essentially what is in CreateScheduledTask
. For example:
<CustomAction Id="RemoveScheduledTask_Rollback" Return="ignore" 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="rollback" />
<InstallExecuteSequence>
<Custom Action="RemoveScheduledTask_Rollback" Before="RemoveScheduledTask"">
REMOVE="ALL"
</Custom>
</InstallExecuteSequence>
You will need access to the domain, username and password to create the task the same way it was originally. You can use the Remember Property Pattern to have the properties available during uninstall, although you'll want to add another couple actions to encrypt/decrypt the password before storing it probably.