如何区分任务计划程序1.0和任务计划程序2.0?

发布于 2024-10-08 15:07:13 字数 119 浏览 0 评论 0原文

我有一个使用任务计划程序 1.0(.job 文件)的 C# 应用程序。 我需要扩展应用程序以支持任务计划程序 2.0 (xml)。

我需要一些代码,能够告诉我当前客户机器上正在运行什么类型的 TS。是否可以?

I have an C# application that uses Task Scheduler 1.0 (.job files).
I need to extend the application to support Task Scheduler 2.0 (xml).

I need some code, that is able to tell me what kind of T.S. is running on the current customer machine. Is it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过期以后 2024-10-15 15:07:13

Task Scheduler 2.0 引入了 ITaskService 接口和脚本支持。所以你可以尝试一下这个类的COM对象是否存在。例如,

var t = Type.GetTypeFromProgID("Schedule.Service");
if (null != t) 
{
   // we definitely have 2.0 version
}
else
{
  // 1.0 version
}

免责声明:未经测试的代码。我从 MSDN 示例中获取了 prog id: http: //msdn.microsoft.com/en-us/library/aa446862(v=VS.85).aspx

Task Scheduler 2.0 introduces ITaskService interface and scripting support. So you can try if COM Object for this class exists or not. For example,

var t = Type.GetTypeFromProgID("Schedule.Service");
if (null != t) 
{
   // we definitely have 2.0 version
}
else
{
  // 1.0 version
}

Disclaimer: untested code. I have picked up prog id from MSDN example: http://msdn.microsoft.com/en-us/library/aa446862(v=VS.85).aspx

花海 2024-10-15 15:07:13

您可以查看 schedsvc.dll 的各个版本(这是实际托管任务计划程序代码的文件),但是您提到的确定计算机操作系统版本然后决定使用哪个版本的任务计划程序的解决方法是正确的一。来自 http://msdn.microsoft.com/ 的文档en-us/library/aa446802(VS.85).aspx,

任务计划程序的安装位置

任务计划程序会自动
安装了多个微软
操作系统。

任务计划程序 1.0 已安装
Windows Server 2003、Windows XP、
和 Windows 2000 操作系统。

任务计划程序 2.0 已安装
Windows Vista 和 Windows Server 2008。

You could poke around the various versions of schedsvc.dll (which is the file that actually hosts the task scheduler code), but the workaround you mention about determining the machine's OS version and then deciding which version of the task scheduler to use is the right one. From the doc at http://msdn.microsoft.com/en-us/library/aa446802(VS.85).aspx,

Where Task Scheduler is Installed

The Task Scheduler is automatically
installed with several Microsoft
operating systems.

Task Scheduler 1.0 is installed with
the Windows Server 2003, Windows XP,
and Windows 2000 operating systems.

Task Scheduler 2.0 is installed with
Windows Vista and Windows Server 2008.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文