尽管正在调用命令,但 TaskScheduler 未创建任务
TaskScheduler not creating task though command is getting called
我有一个 WiX 安装程序,其中我有以下自定义操作来在任务计划程序中创建几个任务。
[CustomAction]
public static ActionResult CreateScheduleTaskForUpdateTriggering(Session session)
{
session.Log("Creating the Scheduled Task");
string MyAppPath = Environment.GetEnvironmentVariable("MyAppPATH");
if (!IsTaskExisting("MyAppUpdateTrigger"))
{
session.Log("Command Created : " + "C:\Windows\System32\SCHTASKS.exe /Create /TN \"MyAppUpdateTrigger\" /SC ONCE /TR \"" + Path.Combine(new string[] { MyAppPath, "Watchdog", "RunMyAppInstaller.bat" }) + "\" /RL HIGHEST");
Process p = Process.Start("C:\Windows\System32\SCHTASKS.exe", " /Create /TN \"MyAppUpdateTrigger\" /SC ONCE /TR \"" + Path.Combine(new string[] { MyAppPath, "Watchdog", "RunMyAppInstaller.bat" }) + "\" /ST 00:00:00 /SD 01/01/1990 /RL HIGHEST");
}
else
{
session.Log("MyAppUpdateTrigger schedule already exists");
}
return ActionResult.Success;
}
[CustomAction]
public static ActionResult CreateScheduleTaskForRunningWatchdog(Session session)
{
session.Log("Creating the Scheduled Task for running watch dog");
string MyAppPath = Environment.GetEnvironmentVariable("MyAppPATH");
if (!IsTaskExisting("RunWatchDog"))
{
session.Log("Command Created : " + "C:\Windows\System32\SCHTASKS.exe /Create /TN \"RunWatchDog\" /SC ONSTART /TR \"" + Path.Combine(new string[] { MyAppPath, "Watchdog", "RunWatchDog.bat" }) + "\" /RL HIGHEST");
Process p = Process.Start("C:\Windows\System32\SCHTASKS.exe", " /Create /TN \"RunWatchDog\" /SC ONSTART /TR \"" + Path.Combine(new string[] { MyAppPath, "Watchdog", "RunWatchDog.bat" }) + "\" /ST 00:00:00 /SD 01/01/1990 /RL HIGHEST");
}
return ActionResult.Success;
}
我在我的 WiX 文件中调用这些,如下所示。
<CustomAction Id="CA_scheduleTaskAction" BinaryKey="removeFolderCustomActionDLL" DllEntry="CreateScheduleTaskForUpdateTriggering" Execute="commit" Return="ignore" />
<CustomAction Id="CA_scheduleTaskActionForWatchDog" BinaryKey="removeFolderCustomActionDLL" DllEntry="CreateScheduleTaskForRunningWatchdog" Execute="commit" Return="ignore" />
<InstallExecuteSequence>
<!--Custom Action="LaunchWatchdog" After="InstallFinalize" /-->
<Custom Action="WatchDog.TaskKill" Before="InstallValidate"/>
<Custom Action="CA_scheduleTaskAction" After="InstallFiles"/>
<Custom Action="CA_scheduleTaskAction" After="InstallFiles"/>
<Custom Action="CA_myCustomAction" Before="InstallFinalize">Installed</Custom>
</InstallExecuteSequence>
虽然第一个计划任务已创建,但任务计划程序中缺少第二个计划任务。日志确实表明自定义操作有 运行。但它不存在于任务计划程序中。当我手动 运行 命令时,它确实被创建了。我在这里做错了什么?任何帮助将非常感激。以下是日志。
Calling custom action CustomActionRemoveFolder!CustomActionRemoveFolder.CustomActions.CreateScheduleTaskForRunningWatchdog
Creating the Scheduled Task for running watch dog
Command Created : C:\Windows\System32\SCHTASKS.exe /Create /TN "RunWatchDog" /SC ONSTART /TR "C:\Program Files\Kube2.0\Watchdog\RunWatchDog.bat" /RL HIGHEST
MSI (s) (88:38) [09:42:01:431]: Note: 1: 2318 2:
MSI (s) (88:38) [09:42:01:431]: No System Restore sequence number for this installation.
MSI (s) (88:38) [09:42:01:431]: Unlocking Server
MSI (s) (88:38) [09:42:01:446]: PROPERTY CHANGE: Deleting UpdateStarted property. Its current value is '1'.
Action ended 9:42:01: InstallFinalize. Return value 1.
Action ended 9:42:01: INSTALL. Return value 1.
现在,我明白了。来自文档:https://msdn.microsoft.com/en-us/library/windows/desktop/bb736357(v=vs.85).aspx
/SC schedule
A value that specifies the schedule frequency. Valid values are: MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONLOGON, ONIDLE, and ONEVENT.
我有一个 WiX 安装程序,其中我有以下自定义操作来在任务计划程序中创建几个任务。
[CustomAction]
public static ActionResult CreateScheduleTaskForUpdateTriggering(Session session)
{
session.Log("Creating the Scheduled Task");
string MyAppPath = Environment.GetEnvironmentVariable("MyAppPATH");
if (!IsTaskExisting("MyAppUpdateTrigger"))
{
session.Log("Command Created : " + "C:\Windows\System32\SCHTASKS.exe /Create /TN \"MyAppUpdateTrigger\" /SC ONCE /TR \"" + Path.Combine(new string[] { MyAppPath, "Watchdog", "RunMyAppInstaller.bat" }) + "\" /RL HIGHEST");
Process p = Process.Start("C:\Windows\System32\SCHTASKS.exe", " /Create /TN \"MyAppUpdateTrigger\" /SC ONCE /TR \"" + Path.Combine(new string[] { MyAppPath, "Watchdog", "RunMyAppInstaller.bat" }) + "\" /ST 00:00:00 /SD 01/01/1990 /RL HIGHEST");
}
else
{
session.Log("MyAppUpdateTrigger schedule already exists");
}
return ActionResult.Success;
}
[CustomAction]
public static ActionResult CreateScheduleTaskForRunningWatchdog(Session session)
{
session.Log("Creating the Scheduled Task for running watch dog");
string MyAppPath = Environment.GetEnvironmentVariable("MyAppPATH");
if (!IsTaskExisting("RunWatchDog"))
{
session.Log("Command Created : " + "C:\Windows\System32\SCHTASKS.exe /Create /TN \"RunWatchDog\" /SC ONSTART /TR \"" + Path.Combine(new string[] { MyAppPath, "Watchdog", "RunWatchDog.bat" }) + "\" /RL HIGHEST");
Process p = Process.Start("C:\Windows\System32\SCHTASKS.exe", " /Create /TN \"RunWatchDog\" /SC ONSTART /TR \"" + Path.Combine(new string[] { MyAppPath, "Watchdog", "RunWatchDog.bat" }) + "\" /ST 00:00:00 /SD 01/01/1990 /RL HIGHEST");
}
return ActionResult.Success;
}
我在我的 WiX 文件中调用这些,如下所示。
<CustomAction Id="CA_scheduleTaskAction" BinaryKey="removeFolderCustomActionDLL" DllEntry="CreateScheduleTaskForUpdateTriggering" Execute="commit" Return="ignore" />
<CustomAction Id="CA_scheduleTaskActionForWatchDog" BinaryKey="removeFolderCustomActionDLL" DllEntry="CreateScheduleTaskForRunningWatchdog" Execute="commit" Return="ignore" />
<InstallExecuteSequence>
<!--Custom Action="LaunchWatchdog" After="InstallFinalize" /-->
<Custom Action="WatchDog.TaskKill" Before="InstallValidate"/>
<Custom Action="CA_scheduleTaskAction" After="InstallFiles"/>
<Custom Action="CA_scheduleTaskAction" After="InstallFiles"/>
<Custom Action="CA_myCustomAction" Before="InstallFinalize">Installed</Custom>
</InstallExecuteSequence>
虽然第一个计划任务已创建,但任务计划程序中缺少第二个计划任务。日志确实表明自定义操作有 运行。但它不存在于任务计划程序中。当我手动 运行 命令时,它确实被创建了。我在这里做错了什么?任何帮助将非常感激。以下是日志。
Calling custom action CustomActionRemoveFolder!CustomActionRemoveFolder.CustomActions.CreateScheduleTaskForRunningWatchdog
Creating the Scheduled Task for running watch dog
Command Created : C:\Windows\System32\SCHTASKS.exe /Create /TN "RunWatchDog" /SC ONSTART /TR "C:\Program Files\Kube2.0\Watchdog\RunWatchDog.bat" /RL HIGHEST
MSI (s) (88:38) [09:42:01:431]: Note: 1: 2318 2:
MSI (s) (88:38) [09:42:01:431]: No System Restore sequence number for this installation.
MSI (s) (88:38) [09:42:01:431]: Unlocking Server
MSI (s) (88:38) [09:42:01:446]: PROPERTY CHANGE: Deleting UpdateStarted property. Its current value is '1'.
Action ended 9:42:01: InstallFinalize. Return value 1.
Action ended 9:42:01: INSTALL. Return value 1.
现在,我明白了。来自文档:https://msdn.microsoft.com/en-us/library/windows/desktop/bb736357(v=vs.85).aspx
/SC schedule
A value that specifies the schedule frequency. Valid values are: MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONLOGON, ONIDLE, and ONEVENT.