WIX创建计划任务

时间:2015-10-16 16:05:12

标签: wix scheduled-tasks

我正在尝试使用WIX创建计划任务。我希望计划任务作为另一个域上的特定用户运行。

我通过属性[Service.User]和[Service.Password]传递给我的用户。

这是我的代码:

<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="&quot;[SystemFolder]SCHTASKS.EXE&quot; /CREATE /SC DAILY /MO 1 /ST 10:00 /TN &quot;CcsReturnProcess&quot; /TR &quot;&quot;[INSTALLFOLDER]CcsReturnProcess.exe&quot;&quot; /RU &quot;[Service.User]&quot; /RP &quot;[Service.Password]&quot; /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="&quot;[SystemFolder]SCHTASKS.EXE&quot; /DELETE /TN &quot;CcsReturnProcess&quot; /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="&quot;[SystemFolder]SCHTASKS.EXE&quot; /CREATE /SC DAILY /MO 1 /ST 10:00 /TN &quot;CcsReturnProcess&quot; /TR &quot;&quot;[INSTALLFOLDER]CcsReturnProcess.exe&quot;&quot; /RU &quot;[Service.Domain]\[Service.User]&quot; /RP &quot;[Service.Password]&quot; /RL HIGHEST" />

好像我的[Service.User]没有被传入。我已经查看了msi日志,它显示用户名和密码是空的???

  

MSI(s)(44:E0)[16:51:48:275]:PROPERTY CHANGE:添加CreateScheduledTask属性。它的值是&#39;&#34; C:\ windows \ SysWOW64 \ SCHTASKS.EXE&#34; / CREATE / SC MINUTE / MO 20 / TN&#34; CcsReturnProcess&#34; / TR&#34;&#34; D:\ ScheduledTasks \ CcsReturnProcess \ CcsReturnProcess.exe&#34;&#34; / RU&#34;&#34; / RP&#34;&#34; / RL最高&#39;。

有人可以建议如何使这个工作吗?

2 个答案:

答案 0 :(得分:6)

用户提供给安装程序的属性必须为uppercase and therefore public

答案 1 :(得分:0)

CreateScheduledTaskId的/ TR参数上的双引号引起了我的失败。这是对我有用的更正版本:

<CustomAction Id="CreateScheduledTaskId"
              Property="CreateScheduledTask"
              Return="check"
              Execute="immediate"
              Value="&quot;[SystemFolder]SCHTASKS.EXE&quot; /CREATE /SC DAILY /MO 1 /ST 10:00 /TN &quot;CcsReturnProcess&quot; /TR &quot;[INSTALLFOLDER]CcsReturnProcess.exe&quot; /RU &quot;[Service.User]&quot; /RP &quot;[Service.Password]&quot; /RL HIGHEST" />