I am trying to get my installer to use a custom action to remove a scheduled task when the application is removed. The custom action for create "CreateScheduledTask" works correctly, however the remove fails.
MSI (s) (B4:D8) [09:28:45:761]: Note: 1: 1721 2: RemoveScheduledTask 3: C:\Foobar\ 4: "C:\Windows\SysWOW64\SCHTASKS.EXE" /DELETE /TN "Automated Admin" /F
Info 1721.There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: RemoveScheduledTask, location: C:\Foobar\, command: "C:\Windows\SysWOW64\SCHTASKS.EXE" /DELETE /TN "Automated Admin" /F MSI (s) (B4:44) [09:28:45:777]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIBB52.tmp, Entrypoint: CommitIIS7ConfigTransaction
The syntax is correct if I run
"C:\Windows\SysWOW64\SCHTASKS.EXE" /DELETE /TN "Automated Admin" /F
from the command line it correctly removes the task.
<!-- Code for setting the automated task-->
<CustomAction Id="CreateScheduledTask"
Return="check"
Impersonate="no"
Execute="deferred"
Directory="INSTALLLOCATION"
ExeCommand=""[SystemFolder]SCHTASKS.EXE" /CREATE /SC MINUTE /MO 15 /TN "Automated Admin" /TR "[AutomatedAdmin]FooBar.exe" /RU "NT Authority\System" /RP /RL HIGHEST" />
Wix fragments are
<CustomAction Id="RemoveScheduledTask"
Return="ignore"
Impersonate="no"
Execute="deferred"
Directory="INSTALLLOCATION"
ExeCommand=""[SystemFolder]SCHTASKS.EXE" /DELETE /TN "Automated Admin" /F" />
<InstallExecuteSequence>
<Custom Action="CreateScheduledTask" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="RemoveScheduledTask" Before="RemoveFiles">REMOVE="ALL"</Custom>
</InstallExecuteSequence>