Wix删除自定义操作失败

时间:2014-01-10 09:39:00

标签: wix wix3.7

我正在尝试让我的安装程序在删除应用程序时使用自定义操作删除计划任务。创建“CreateScheduledTask”的自定义操作正常工作,但删除失败。

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.此Windows Installer程序包存在问题。无法运行此安装所需的程序。请联系您的支持人员或包装供应商。操作:RemoveScheduledTask,位置:C:\ Foobar \,命令:“C:\ Windows \ SysWOW64 \ SCHTASKS.EXE”/ DELETE / TN“自动管理”/ F MSI(s4)(B4:44)[09:28:45:777]:调用远程自定义操作。 DLL:C:\ Windows \ Installer \ MSIBB52.tmp,入口点:CommitIIS7ConfigTransaction

如果我运行

,语法是正确的
"C:\Windows\SysWOW64\SCHTASKS.EXE" /DELETE /TN "Automated Admin" /F 

从命令行中正确删除任务。

<!-- Code for setting the automated task-->
<CustomAction Id="CreateScheduledTask" 
Return="check" 
Impersonate="no" 
Execute="deferred" 
Directory="INSTALLLOCATION" 
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /CREATE /SC MINUTE /MO 15 /TN &quot;Automated Admin&quot;  /TR &quot;[AutomatedAdmin]FooBar.exe&quot; /RU &quot;NT Authority\System&quot; /RP /RL HIGHEST" />

Wix片段

<CustomAction Id="RemoveScheduledTask" 
Return="ignore" 
Impersonate="no" 
Execute="deferred" 
Directory="INSTALLLOCATION" 
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /DELETE /TN &quot;Automated Admin&quot; /F" />

<InstallExecuteSequence>
  <Custom Action="CreateScheduledTask" Before="InstallFinalize">NOT Installed</Custom>
  <Custom Action="RemoveScheduledTask" Before="RemoveFiles">REMOVE="ALL"</Custom>
</InstallExecuteSequence>

1 个答案:

答案 0 :(得分:3)

您的代码看起来正确,这是我的配置,编译为x86 .msi,我在Windows 8.1 x64 / x86和Windows Server 2008r2 x64上进行了测试。将UAC设置为默认值并禁用。 (.msi将提示管理员权限)

<CustomAction Id="TaskDelete" Return="ignore" Execute="deferred" Directory="TARGETDIR" Impersonate="no"
 ExeCommand="SCHTASKS.EXE /DELETE /TN &quot;My Client Service&quot; /F" />

<CustomAction Id="TaskCreate" Return="check" Execute="deferred" Directory="TARGETDIR" Impersonate="no" 
 ExeCommand="SCHTASKS.EXE /CREATE /SC MINUTE /MO 20 /TN &quot;My Client Service&quot; /TR &quot;sc.exe start My_Client_Service&quot; /RU SYSTEM /RP /RL HIGHEST /F" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLDIR" Name="My Company" >
...components...
   </Directory>
  </Directory>
</Directory>

<InstallExecuteSequence>
  <!--Remove task on Uninstall or Upgrade-->
  <Custom Action='TaskDelete' Before="TaskCreate">REMOVE="ALL"</Custom>
  <!--Add task on Install or Upgrade-->
  <Custom Action='TaskCreate' Before="InstallFinalize">(NOT Installed) OR UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>