How to schedule a task with wix?

windows-xp, wix

Solution

You didn't include when your CustomAction takes place in the Install Sequence. If it should be after the installation or upon close.

  <InstallExecuteSequence>
     <Custom Action='CreateScheduledTask' After='InstallFiles'/>
  </InstallExecuteSequence> 

Also, nesting quotes never works for me. I use `&quot;` inside any quotes. Here's an example creating a service.

<CustomAction Id="MyService" 
              Property="CMD" 
              ExeCommand="[SystemFolder]cmd.exe /c sc create &quot;MyService&quot;  binPath= &quot;[#MyService.exe]&quot; start= auto  type= interact type= own" 
              Execute="deferred" 
              Return="check" 
              Impersonate="no"/>

Problem

I am trying to schedule a task with wix installer.Installer is installed successfully but the task is not added to task scheduler.I am using windows xp. ``` <Product Id="*" Name="FooBar" Language="1033" Version="1.0.0.0" Manufacturer="Foo" UpgradeCode="GID"> <Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/> ... </Product> <Fragment> <CustomAction Id="CreateScheduledTask" Return="check" Impersonate="no" Execute="deferred" Directory="TARGETDIR" ExeCommand=""[SystemFolder]SCHTASKS.EXE" /CREATE /SC MINUTE /MO 20 /TN "Foobar" /TR "[INSTALLFOLDER]\Foobar.exe" /RU "NT Authority\System" /RP" /> </Fragment> ```

Original source