MikeW
MikeW

Reputation: 57

How do you programmatically turn off the Windows XP Print Spooler service in C#

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!

Upvotes: 3

Views: 3551

Answers (3)

Thomas Levesque
Thomas Levesque

Reputation: 292695

You can probably do that using the ServiceController class :

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

Upvotes: 5

ChrisW
ChrisW

Reputation: 56123

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

Upvotes: 0

Related Questions