Start Windows Service programmatically

后端 未结 6 2190
遥遥无期
遥遥无期 2020-12-08 00:02

I am having an issue with an application that I am creating. I am trying to start a windows service through my C# app. When I click my start button, it looks like everythi

6条回答
  •  不思量自难忘°
    2020-12-08 00:34

    This is an old thread, but google got me here. My services, even after successfully starting, would still query back as stopped. If you add

    service.Refresh();
    

    It will query the actual current status instead of the stored state from a previous query. I don't know why it works like this, but it does.

    P.S.: I added a minute long time out and still got a service is stopped response without the refresh.

提交回复
热议问题