如何使用wix安排任务?

时间:2013-12-06 07:45:19

标签: wix windows-xp

我正在尝试使用wix installer安装任务.Installer已成功安装,但任务未添加到任务调度程序。我正在使用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>

2 个答案:

答案 0 :(得分:3)

当您的CustomAction在安装顺序中发生时,您没有包含。如果应该在安装后或关闭时。

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

此外,嵌套引号永远不适合我。我在任何引号中使用&quot;。这是创建服务的示例。

<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"/>

答案 1 :(得分:0)

以下是最终为我工作的内容(改编自http://kamivaniea.com/?p=632):

<InstallExecuteSequence>
  <Custom Action="CreateScheduledTask" After="InstallFiles">
    NOT Installed
  </Custom>
</InstallExecuteSequence>

<CustomAction Id="CreateScheduledTask"
    Return="check"
    Impersonate="no"
    Execute="deferred"
    Directory="TARGETDIR"
    ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /Create /TN &quot;Task Name Here&quot; /TR &quot;[INSTALLFOLDER]MyExecutable.exe&quot; /SC WEEKLY /D MON /ST 05:00 /F" />

当我做了Val建议我在日志(msiexec /l*v log.txt /i MyInstaller.msi)中收到此错误时:

  

错误1721.此Windows Installer程序包存在问题。无法运行此安装所需的程序。请联系您的支持人员或软件包供应商。

这就是我所拥有的:

<InstallExecuteSequence>
  <Custom Action='CreateScheduledTask' After='InstallFiles'/>
</InstallExecuteSequence>
<CustomAction Id="CreateScheduledTask"
  Property="CMD"
  ExeCommand="[SystemFolder]cmd.exe /c schtasks /Create /TN &quot;Task Name Here&quot; /TR &quot;[INSTALLFOLDER]MyExecutable.exe&quot; /SC WEEKLY /D MON /ST 05:00 /F"
  Execute="deferred"
  Return="check"
  Impersonate="no"/>