通过 C# winform 应用程序添加和编辑计划任务
我编写了一个驻留在 Windows 2008 服务器上的 Windows 服务。我还开发了一个单独的 C# winforms 应用程序,我想用它来配置服务的任务以安排其运行。
winforms 应用程序是一个表单 UI,具有基本的调度输入,例如星期几、一天中的时间等。我希望用户选择输入并将其保存为一个任务,该任务将调度我的 win 服务的运行。
有没有办法通过 C# winform 添加/编辑 Windows 计划任务而不使用第 3 方加载项?
I wrote a windows service that resides on a windows 2008 server. I also developed a separate C# winforms application that I'd like to use to configure a task for the service to schedule its run.
The winforms app is a form UI with basic scheduling inputs such as day of week, time of day, etc. I'd lke the user to choose inputs and save this as a task that will schedule the running of my win service.
Is there a way to add/edit a windows scheduled task via C# winform without using 3rd party add-ons?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或者,您可以将服务编写为始终运行,并让它在应该运行时引用数据库表。该服务将简单地检查何时允许其运行。
您的 WinForm 应用程序可以简单地更新数据库表。真的很简单。当然,您可以使其变得无限复杂,但是,您所描述的内容似乎相对简单。
Alternatively, you could write the service to always be running, and have it reference a database table on when it should run. The service would simply check when it is allowed to run.
Your WinForm application could simply update the database table. Quite simple really. Of course you could make it infinitely more complex, but, for what you are describing seems relatively simple.
我认为没有办法使用纯托管代码,但是如果您添加对 TASK Scheduler COM Library,你应该可以做到。 (引用...添加引用...Com 对象)
I don't think there's a way using purely managed code, but if you add a reference to the TASK Scheduler COM Library, you should be able to do it. (References... Add Reference... Com Objects)