How to restart service remotely?

前端 未结 3 1552
南笙
南笙 2021-02-07 10:57

I can start or stop service remotely from .net project.

ConnectionOptions options = new ConnectionOptions();
options.Username = @\"192.168.36.22\\test\";
options         


        
3条回答
  •  走了就别回头了
    2021-02-07 11:29

    You could use the ServiceController class like so:

    ServiceController sc = new ServiceController("ArcGIS Server", "192.168.36.22");
    
    sc.Start();
    sc.Stop();
    

    This saves you having to write all that code to interact with WMI. Note to use the ServiceController class, you'll have to add a reference to the System.ServiceProcess assembly.

提交回复
热议问题