Search code examples
c#windows-serviceswindows

cannot open window service on computer '.' in window application


I develop one window application and I also create one service. I start the service using coding in window application, but I am getting an error like:

Cannot open window service on computer '.'.

I have used below code:

ServiceController controller = new ServiceController("SeoMozScheduleService");
                
if (controller.Status == ServiceControllerStatus.Stopped)
{
    controller.Start();
}

If I right-click on Application and click on Run as Administrator than it works fine for me.


Solution

  • Go to c://Program Files/ApplicationFolder/.exe Right-click on .exe and go to Properties then go Compatibility Tab and check true to Run this Program as an administrator Level.