0

I have winforms application which accesses WCF service on some Windows machine on same network. Sometimes WCF service is down due to some error in it, i want to be able to access machine with service and start the service up if it's down.

I want to do that from WinForms C# application.

How do i access Windows machine from WinForms application and execute command on it. ie

sc \machine stop

eugeneK
  • 10,750
  • 19
  • 66
  • 101

1 Answers1

2

Try the System.ServiceProcess.ServiceController class.

var svc = new ServiceController("WCFServiceName", "ComputerName");
if (svc.Status == ControllerStatus.Stopped)
{
  sc.Start();
}
Simon
  • 1,211
  • 9
  • 5