Takes an input of "Servicename" and starts or stops it accordingly
try
{
//Start, Stop, Pause, Continue, Refresh and Close a Service
string serviceName = "DentsplySirona - Kanban Notification Service";
ServiceController service = new ServiceController(serviceName);
if ((service.Status.Equals(ServiceControllerStatus.Stopped)) || (service.Status.Equals(ServiceControllerStatus.StopPending)))
{
service.Start();
MessageBox.Show($"{serviceName} was started");
}
else
{
service.Stop();
MessageBox.Show($"{serviceName} was stopped");
}
}
catch (Exception up)
{
throw up.InnerException;
}