You develop an application named myApp. This application needs to run on the same computer as a Windows service named myService. You want to ensure that myService starts from myApp if myService is not already running. Which code segment should you use?
A.
ServiceController myServiceController = new
ServiceController(“myService”);
if (myServiceController.Status ==
ServiceControllerStatus.Stopped) {
myServiceController.Start();
}
B.
ServiceController myServiceController = new
ServiceController(“myService”);
myServiceController.Start();
C.
string[] myArgs = new string[1];
myArgs[0] = “myService”;
ServiceController myServiceController = new
ServiceController();
if (myServiceController.Status ==
ServiceControllerStatus.Stopped) {
myServiceController.Start(myArgs);
}
D.
string[] myArgs = new string[1];
myArgs[0] = “myService”;
ServiceController myServiceController = new
ServiceController();
myServiceController.Start(myArgs);