VirtualServer2005用ツールの自作 その5

Virtual Serverが起動されていないせいでエラーになるのであれば、起動するまで待てばよいと。

サービス操作関連は「System.ServiceProcess」名前空間にあるクラスを使えば簡単に操作できます。
サービスが、とある状態になるまで待機するメソッドとして「System.ServiceProcess.ServiceController.WaitForStatus()」があるので、これを使います。
            Dim sc As New System.ServiceProcess.ServiceController("Virtual Server")

            Console.WriteLine("VirtualServer起動待ち")
            sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running)
            Console.WriteLine("VirtualServer起動確認完了")
        End Sub
これで、Virtual Serverが起動してから操作が行えるようになりました。

思ったより結構手間がかかりましたが、これで運用できそうです。

とっととHyper-Vにしたい!!

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny