Windowsサービスの状態を取得したり動かしたり
using System.ServiceProcess;
// Print Spooler = サービス名
using (ServiceController sc = new ServiceController("Print Spooler"))
{
//プロパティ値を更新
sc.Refresh();
if (sc.Status == ServiceControllerStatus.Stopped)
{
// サービスが止まってたら動かす
sc.Start();
// サービスが動くまで最大1分間待つ
sc.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 1, 0));
}
}