Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 虽然调用了命令,但TaskScheduler未创建任务_C#_Wix_Windows Installer_Scheduled Tasks_Custom Action - Fatal编程技术网

C# 虽然调用了命令,但TaskScheduler未创建任务

C# 虽然调用了命令,但TaskScheduler未创建任务,c#,wix,windows-installer,scheduled-tasks,custom-action,C#,Wix,Windows Installer,Scheduled Tasks,Custom Action,我有一个WiX安装程序,其中我有以下自定义操作来在任务调度器中创建两个任务 [CustomAction] public static ActionResult CreateScheduleTaskForUpdateTriggering(Session session) { session.Log("Creating the Scheduled Task"); string MyAppPath = Environmen

我有一个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>
现在,我明白了。从文件:

/SC时间表

指定计划频率的值。有效值为:分钟、小时、每日、每周、每月、一次、ONLOGON、ONIDLE和ONEVENT


您是否尝试过更可靠的编程方式。我打印了错误代码。这就是我得到的。“-2147467259”有什么想法吗(这是一个运行时错误,原因可能会有所不同。很难说。解决了这个问题。这与“启动”命令有关。当我说“一次”时,它可以正常工作。有什么想法吗?哦!我如何通过命令行发出此onstart命令?因为任务调度器计划的其他方法需要一些代码更改:(也在这里,他们说这是可以做到的不?此外,当我通过命令行手动运行此命令时,它会起作用!对,文档有点混乱。我现在正在遍历它。试试这个,将您的示例与您的进行比较。
    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.