Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9763

Windowsサービスの実行状態を取得/実行

$
0
0
Windowsサービスの状態を取得したり動かしたり // 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)); } }

Viewing all articles
Browse latest Browse all 9763

Trending Articles