如何在C#中计划Windows服务?

如何在C#中计划Windows服务?

问题描述:

            I have created windows service in c#. I would like to schedule windows service manually or by coding .How can I do this.

实际上,我在找

我的服务应该每天早上9点开始,并在一段时间后停止我的服务.由于Microsoft在Windows XP中提供了计划任务",因此我们可以在其中计划任何exe.以同样的方式如何安排任何Windows服务在指定时间执行?

感谢您的帮助

问候

Rajesh

您可以使用net命令:

You can use the net command:

net start myservicename

net start myservicename

net stop myservicename

net stop myservicename

或者,您可以使用ServiceController类编写自己的代码.

Or, you can write your own by using the ServiceController class.