VB.NET中的任务计划程序(2010) [英] Task Scheduler in VB.NET (2010)

查看:75
本文介绍了VB.NET中的任务计划程序(2010)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道您如何通过VB.NET对Task进行编程以使其自动在Task Scheduler中执行吗?

我收到了老师的作业(对我来说这是一个艰巨的任务),我必须在Visual Basic Express中设计一个程序,这样它才能将一些文件从一个位置复制到另一个位置(这并不困难,我认为),但必须在指定的时间完成...

而且我记得,您可以使用Windows本身的Task Scheduler来执行此操作,对吗?但这是问题开始出现的时候……在作业中,我不允许物理上使用任务计划程序……我必须以某种方式对其进行编程,以便程序"将自己放置或安排在任务中调度程序.

你到底是怎么做到的?

最后,我必须向我的老师发送一封电子邮件,告知我程序的结果(程序完成,仍在运行还是处于非活动状态).

请有人帮我!我肯定会被卡住...这有点像我的年度任务...因此,如果有人可以帮助我,那将非常有帮助.

非常感谢!

Jorre

Does anyone have an idea how you are able to program a Task via VB.NET to automatically let it execute in Task Scheduler?

I received an assignment from my teacher (it''s a tough one for me), and I have to design a program in Visual Basic Express, so it would copy some files from one place to another (that''s not that tough, I think), but it has to be done on a specified time ...

And as I recall, you are able to do this with Task Scheduler from Windows itself, right? But this is were the problem starts showing up ... in the assignment, I''m not allowed to use the Task Scheduler physically ... I have to program it somehow so "the program" would put itself or schedule itself in Task Scheduler.

How on earth do you do this?

And as a finishing touch, I have to send an e-mail to my teacher with the results of my program (wether it''s finished, still running or inactive).

PLEASE, someone help me! I''m stuck for sure ... And it''s sort of my year assignment ... So it would be really helpfull if someone could help me out.

Thanks alot!

Jorre

推荐答案

基于计时器事件创建Windows服务:
create a windows service based om a timer event: http://www.devtips.net/Artikel.aspx?id=38[^]


您知道使用任务计划程序可以做到的,更优雅的解决方案.也可以通过您的程序或Windows服务来完成.您可以将数据存储在xml文件中,程序可以通过计时器对其进行解析.
You know using the Task Scheduler can be done, more elegant solution. It also could be done via your program or windows service. You could store the data in an xml file and your program can parse it via a timer.


无论如何我都解决了问题:)

这就是使之成为可能的代码

Process.Start("schtasks","/一次创建一次/sc/sd [日期]/st [时间]/tn [名称]/tr [触发]")

对于邮件,感谢VBScript,效果很好.
I fixed it anyway :)

this was the code that made it possible

Process.Start("schtasks","/create /sc once /sd [date] /st [time] /tn [Name] /tr [trigger]")

and for the mail, thanks to VBScript, it worked out just fine.


这篇关于VB.NET中的任务计划程序(2010)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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