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...
1] Check Services Startup type To manage Windows Services, you have to open the Run box, type services. msc and hit Enter to open the Services Manager. Here you can set its startup type to Automatic, Delayed, Manual or Disabled. Check if the specific service with whom you are facing problems is not set to Disabled.
Windows service is a computer program that runs in the background to execute some tasks. Some examples of Windows services are auto-update of Windows, check emails, print documents, SQL Server agent, file and folder scanning and indexing and so on.
A ServiceController component allows us to access and manage Windows Services running on a machine. In this article, I will discuss how to use a ServiceController class to load all services and get information about them in a Windows Forms application using Visual Studio 2010. Adding System.ServiceProcess Reference.
To make this automatic every time you open the application you have to add a manifest file to your solution, then update the requestedExecutionLevel
node inside the file to look like this:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> </requestedPrivileges>
However, changing this setting will result in the system prompting you every time to run the application as administrator if UAC is enabled.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With