Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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...

like image 800
Kartik Patel Avatar asked Jan 24 '13 12:01

Kartik Patel


People also ask

How to Check why service is not starting?

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.

What is Windows service example?

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.

What is service controller?

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.


2 Answers

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.

like image 173
Ahmed Elbatt Avatar answered Oct 14 '22 07:10

Ahmed Elbatt


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.

like image 30
Kartik Patel Avatar answered Oct 14 '22 05:10

Kartik Patel