我有一个 WiX 设置
<MajorUpgrade Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
如果在升级过程中发生错误,安装程序会回滚并恢复之前安装的版本。但是,通过自定义操作创建的计划任务会丢失并且永远不会恢复。
我用于创建/删除/回滚任务的自定义操作是:
<!-- task scheduling -->
<CustomAction Id="CreateScheduledTask" Return="check" Directory="SystemFolder"
ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Create /RU "[TASK_DOMAIN]\[TASK_USERNAME]" /RP [TASK_PASSWORD] /SC DAILY /TN "Maintenance" /TR "[\\]"[SERVICELOCATION]Maintenance.exe[\\]"" /ST [TASK_TIME]"
Execute= "deferred"/>
<!-- rollback in case something went wrong -->
<CustomAction Id="CreateScheduledTask_Rollback" Execute="rollback" Return="ignore" Directory="SystemFolder" ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Delete /TN "Maintenance" /F" />
<!-- removal of task -->
<CustomAction Id="RemoveScheduledTask" Return="ignore" Directory="SystemFolder" ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Delete /TN "Maintenance" /F" Execute= "immediate"/>
排队为
<InstallExecuteSequence>
<Custom Action="CreateScheduledTask_Rollback" Before="CreateScheduledTask"></Custom>
<Custom Action="CreateScheduledTask" Before="InstallFinalize"></Custom>
<Custom Action="RemoveScheduledTask" Before="RemoveFiles">
<![CDATA[(REMOVE="ALL")]]>
</Custom>
</InstallExecuteSequence>
CreateScheduledTask
-action 有一个条件NOT Installed
,我出于测试目的删除了该条件。
谁能告诉我,为了在升级设置回滚时重新创建任务,我需要做什么?PS:我无权访问最初创建任务时使用的域、用户名或密码。