I am trying to start a service from my wpf Application and i am getting Cannot open SERVICENAME service on computer when i try to start/stop the service….
I have to do this programmatic i cannot change any setting or permissions manually…
ServiceController service = ServiceController.GetServices().FirstOrDefault(i => i.ServiceName.Contains("SERVICENAME"));
if (service.Status != ServiceControllerStatus.Running)
{
service.Start();// /// Cannot open SERVICENAME service on computer '.'.
service.WaitForStatus(ServiceControllerStatus.Running);
}
I’d guess that you don’t have sufficient rights to control services due to UAC. Try running as admininstrator, i.e. elevating your priviliges.