以编程方式设置计划任务
我的应用程序需要在安装时设置计划任务。任务是在多个触发器(与登录事件相关)上运行我的程序。我想知道最简单的方法是什么?我应该使用批处理文件吗?
该程序仅在 Windows 7 上运行。
My application needs to set up a scheduled task on installation. The task is to run my program on several triggers (related to logon events). I am wondering what is the easiest way to do this? Should I use a batch file?
This program will run only on Windows 7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这听起来更像是 WindowsService,而不是计划任务。 SystemEvents 类文档 包含设置然后,WindowsService 将监视各种系统事件(包括 SessionEnding 和 SessionSwitch)。监控登录事件会很困难,因为那里存在先有鸡还是先有蛋的问题。另一方面,添加一个在启动时运行的应用程序相对简单,并且会让您知道用户已登录......
That sounds more like a WindowsService than a scheduled task. The SystemEvents Class documentation includes an example of setting up a WindowsService that will then monitor for various system events (including SessionEnding and SessionSwitch). Monitoring for logon events would be difficult as you have something of a chicken/egg problem there. On the other hand, adding an application to run on startup is relatively simple and would let you know that a user has logged on...