如何以编程方式关闭C#中的Windows XP Print Spooler服务

时间:2022-10-30 21:32:19

I need to write a small console app (patch) that turns off the print spooler service, does a few things, then starts the print spooler service. I'd like to write this in C#. Can someone point me in the right direction? Thanks in advance!

我需要编写一个小的控制台应用程序(补丁)来关闭打印后台处理程序服务,执行一些操作,然后启动打印后台处理程序服务。我想用C#写这个。有人能指出我正确的方向吗?提前致谢!

3 个解决方案

#1


You can probably do that using the ServiceController class :

你可以使用ServiceController类来做到这一点:

ServiceController controller = new ServiceController("Spooler");
controller.Stop();
...
controller.Start();

#3


I suspect you use the ServiceController class to control (i.e. to stop and start) the service whose name is spooler.

我怀疑你使用ServiceController类来控制(即停止和启动)名称为假脱机程序的服务。

#1


You can probably do that using the ServiceController class :

你可以使用ServiceController类来做到这一点:

ServiceController controller = new ServiceController("Spooler");
controller.Stop();
...
controller.Start();

#2


#3


I suspect you use the ServiceController class to control (i.e. to stop and start) the service whose name is spooler.

我怀疑你使用ServiceController类来控制(即停止和启动)名称为假脱机程序的服务。