SchTasks.exe会VS ITaskScheduler [英] schtasks.exe vs ITaskScheduler

查看:232
本文介绍了SchTasks.exe会VS ITaskScheduler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着写一些code自动配置一帮一台机器上的计划任务。该程序将读取XML文件,然后根据XML文件中的信息配置任务的运行时间等。

I'm trying to write some code to automatically "configure" a bunch of scheduled tasks on a machine. The program will read an XML file then "configure" the run times etc. of the task based on the information in the XML file.

的思路应该是,该方案可以在机器上跑多次,并自动添加/删除任何有效的改变。该办法,我想这样做,这是如下:

The idea should be that the program can be "run" multiple times on the machine and automatically "add/remove" any effective changes. The way I was wanting to do this was as follows:

  1. 所有的任务都与一些特殊的preFIX创建。当程序运行时,它删除的所有任务与preFIX因为它们可以被认为已经运行通过用不同,早期,配置该程序

  1. All tasks will be created with some special "prefix". When the program runs, it "deletes" all tasks with that prefix as they can be assumed to have been run by the program with a different, early, configuration.

然后程序创造了新的任务。

The program then "creates" the new tasks.

所以,我的配置的方案需要能够

So my "configuration" program needs be able to

  1. 获取所有现有的计划任务列表中的计算机上
  2. 按名称删除任务
  3. 按名称创建新任务

这将是最简单的,如果我可以在C#编写程序。

It will be simplest if I can write the program in C#.

似乎有两种方式,我可以做到这一点:

There appear to be two ways I can do this:

  1. 在C#程序显式运行SchTasks.exe将计划用适当的命令行参数。据读和解析SchTasks.exe将输出以获得现有的任务列表,以便它可以删除它们。然后,它运行SchTasks.exe会再次创造了新的任务。

  1. The C# program explicitly runs the "schtasks.exe" program with appropriate command line parameters. It "reads" and parses the output of schtasks.exe to get the list of existing tasks so that it can delete them. It then runs schtasks.exe again to create the new tasks.

通过.NET COM包装使用ITaskManager接口以编程方式查询并安排任务。

Use the ITaskManager interface via a .NET COM wrapper to programmatically query and schedule the tasks.

我倒是preFER去与#2,但我怀疑,这是老的功能 - 我可以在网上找到意味着自Windows NT的任务管理器功能有所改善

I'd prefer to go with #2 but I have a suspicion that this is "older" functionality - what I can find on the web implies that task manager functionality has improved since Windows NT.

时SCHTASKS.EXE一个简单的命令行工具,写上ITaskManager COM接口之上?还是有事情,所以SchTasks.exe可以做到这一点的ITaskManager接口不?

Is schtasks.exe simply a command line tool written on top of the ITaskManager COM interface? Or are there things that schtasks.exe can do that the ITaskManager interface does not?

请问ITaskManager接口/ COM组件生成任务计划文件夹.JOB文件?

Does the ITaskManager interface/COM component generate ".job" files in the Scheduled tasks folder?

推荐答案

我在使用这个库的一些成功: HTTP://www.$c$cproject.com/KB/cs/tsnewlib.aspx

I am having some success using this library: http://www.codeproject.com/KB/cs/tsnewlib.aspx

这似乎是在内部使用ITaskScheduler COM接口,并公开了我需要的功能。

It appears to use the ITaskScheduler COM interface internally and exposes the functionality that I need.

感谢马蒂亚斯您的快速回答太(upvoted)。

Thanks Mattias for your quick answer too (upvoted).

这篇关于SchTasks.exe会VS ITaskScheduler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆