How can I programmatically stop/start a windows service on a remote box?

后端 未结 9 1766
清歌不尽
清歌不尽 2020-11-27 05:17

I want to write a console or Click Once WinForms app that will programmatically stop and/or start a windows service on a remote box.

Both boxes are running .NET 3.5

9条回答
  •  天涯浪人
    2020-11-27 05:32

    You can also do this from a command console using the sc command:

     sc  start [service name]
     sc  stop [service name]
    

    Use

    sc  query | find "SERVICE_NAME"
    

    to get a list of service names.

    The option has the form \\ServerName

    Example

    sc \\MyServer stop schedule will stop the Scheduler service.

提交回复
热议问题