问题描述
我读过几篇文章在这里StackOverflow的有关任务调度,但我不知道,我得到它的权利。我编码(在VB.Net)的备份应用程序,我想补充的计划任务(其实,我只是想,让用户决定每天运行它,例如,3 AM)。
I've read a few posts here on StackOverflow about task scheduling, but I'm not sure that I get it right. I'm coding (in VB.Net) a backup application, that I'd like to add as a scheduled task (in fact, I'd just like to let the user decide to run it every day at, for example, 3 AM).
我读过的帖子建议使用Windows服务这一点,但它听起来有点多了一些简单的周期性运行的任务,不是吗?
I've read posts suggesting to use a windows service for this, but it sounds a bit to much for something as simple as periodically running a task, isn't it?
你能告诉我如何简单地设置在VB.Net计划任务?我试图让我的code尽可能轻。
Could you please advise me on how to simply set a scheduled task in VB.Net? I'm trying to keep my code as lightweight as possible.
推荐答案
最好的办法是不要的写的调度,但使用内置的Windows计划程序执行$ C $ C。
The best thing is to not write a scheduler, but use the built-in Windows scheduler to run your code.
更多信息:
http://support.microsoft.com/kb/308569
请注意:如果你计划一个任务来下一个帐户,而不是你自己的其他运行,应用程序可能无法访问网络驱动器或其他资源。换句话说,可能有一些安全挑战的工作,通过,特别是对于像的备份应用程序。
Note: if you schedule a task to run under an account other than your own, the application may not have access to network drives or some other resources. In other words, there may be some security challenges to work through, particularly for something like a backup app.
如果这仅仅是一个个人应用程序进行备份,我的建议是使用XCOPY从一个批处理文件,而不是重新发明轮子。
If this is just a personal app for backup, my recommendation would be to use XCOPY from a batch file rather than re-inventing the wheel.
这篇关于建立在.net计划的任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!