Stopping/Starting a remote Windows service and waiting for it to open/close

后端 未结 11 1511
广开言路
广开言路 2020-12-02 06:42

The top answer to this question tells me how to stop/start a remote service. Great. Now, all I need is to wait for the actual stop/start to complete. So, what I\'m looking f

11条回答
  •  抹茶落季
    2020-12-02 07:27

    I don't believe you can do this with a straight dos command. You might check Code Project or other similar sites to see if there's a custom solution for this already.

    If not, you could write a secondary Windows service that does this for you by exposing the start/stop functionality through a WCF endpoint. To access this secondary service remotely, you could write a simple console app that connects to this service to start/stop the Windows service in question. Since it's a console app, it would mimic the desired behavior of working from the command line and not returning until complete (or an error occurred). It's not the straightforward, simple solution you're looking for, but I'll throw it out there for consideration.

提交回复
热议问题