I am trying to create a scheduled task using WIX. I want the scheduled task to run as a specific user on another domain.
I pass in my user through a property [Service.User] and [Service.Password].
Here is my code:
<InstallExecuteSequence>
<Custom Action="CreateScheduledTask" After="InstallFiles">NOT Installed</Custom>
<Custom Action="CreateScheduledTaskId" After="CostFinalize">NOT Installed </Custom>
<Custom Action="DeleteScheduledTaskId" After="CostFinalize">Installed</Custom>
<Custom Action="DeleteScheduledTask" Before="RemoveFiles">Installed </Custom>
</InstallExecuteSequence>
<!--Create CcsReturnProcess Scheduled Task-->
<CustomAction Id="CreateScheduledTaskId"
Property="CreateScheduledTask"
Return="check"
Execute="immediate"
Value=""[SystemFolder]SCHTASKS.EXE" /CREATE /SC DAILY /MO 1 /ST 10:00 /TN "CcsReturnProcess" /TR ""[INSTALLFOLDER]CcsReturnProcess.exe"" /RU "[Service.User]" /RP "[Service.Password]" /RL HIGHEST" />
<CustomAction Id="CreateScheduledTask"
Return="check"
Impersonate="no"
Execute="deferred"
BinaryKey="WixCA"
DllEntry="CAQuietExec" />
<!--Delete CcsReturnProcess Scheduled Task-->
<CustomAction Id="DeleteScheduledTaskId"
Property="DeleteScheduledTask"
Return="check"
Execute="immediate"
Value=""[SystemFolder]SCHTASKS.EXE" /DELETE /TN "CcsReturnProcess" /F" />
<CustomAction Id="DeleteScheduledTask"
Return="check"
Impersonate="no"
Execute="deferred"
BinaryKey="WixCA"
DllEntry="CAQuietExec" />
Trying the below does not work either.
<CustomAction Id="CreateScheduledTaskId"
Property="CreateScheduledTask"
Return="check"
Execute="immediate"
Value=""[SystemFolder]SCHTASKS.EXE" /CREATE /SC DAILY /MO 1 /ST 10:00 /TN "CcsReturnProcess" /TR ""[INSTALLFOLDER]CcsReturnProcess.exe"" /RU "[Service.Domain]\[Service.User]" /RP "[Service.Password]" /RL HIGHEST" />
It seems like my [Service.User] is not being passed in. I've had a look at the msi log and it shows that the username and password is empty???
MSI (s) (44:E0) [16:51:48:275]: PROPERTY CHANGE: Adding CreateScheduledTask property. Its value is '"C:\windows\SysWOW64\SCHTASKS.EXE" /CREATE /SC MINUTE /MO 20 /TN "CcsReturnProcess" /TR ""D:\ScheduledTasks\CcsReturnProcess\CcsReturnProcess.exe"" /RU "" /RP "" /RL HIGHEST'.
Can anyone advise how to get this working?
Properties that the user provides to the installer must be uppercase and therefore public.
The double double-quotes on /TR param of CreateScheduledTaskId caused a failure for me. Here's the corrected version that worked for me: