servicecontroller

Control a service on a remote server from IIS

Please note: In each step I describe below I'm logged in as the same domain user account. I have a web application that controls a service on a remote machine (via ServiceController). When I connect to the website remotely and attempt to control the service, I get an InvalidOperationException: Access is denied. I know it CAN work, b...

ServiceController Required Privileges

I'm using a ServiceController to Start services on a remote machine. When I want to query the services on that machine, I get the following exception: Cannot open Service Control Manager on computer 'machinename'. This operation might require other privileges. What privileges are required to query/start/stop the services on a remote ma...

Checking for an unregistered/missing service

How can I use ServiceController to tell me if a service has been registered or not? In the code fragment below, the check for a null DisplayName results in a System.InvalidOperationException. Is there a straightforward way of doing this that I'm completely missing? ServiceController sc = new ServiceController("TestService"); if (sc.D...

Send command to service from C++

Hello, how can I send command to a Windows service from C++? Equivalent .NET code is: ServiceController sc = new ServiceController("MyService"); sc.ExecuteCommand(255); ...

unable to install window service using 'servicecontroller'

Hi, I want to install a windows service on a remote service. In the following blog you have said to use 'servicecontroller' http://stackoverflow.com/questions/469397/installing-a-win32-service-using-msbuild-and-microsoft-sdc-tasks However in the 'ServiceController Members' in the .chm file of 'MSBuild Community Tasks' there is no me...

View status of service running on remote machine

The conditions are - I don't have administrator privilege - I want to see the status of a service in remote machine (server) I use the following code (vb.net with framework 2.0) to see the status Dim sqlSvc As ServiceController Svc = New ServiceController(My.Settings.serviceName, My.Settings.machineName) If sqlSvc.Status.ToString.Equal...

how to get phyiscal path of windows service using .net?

I have to get the absolute path of a windows service in a .Net Admin application. I am using ServiceController of .Net as shown below. ServiceController serviceController = new ServiceController(serviceName); But I don't see any property here to get the absolute path of the .exe of the service. Is there anyway to get this programmati...

ServiceController.Stop() doesn't appear to be stopping anything

My dev box is a Windows 7 (x64) machine. I've got some code (C#, .net 2.0) that in certain circumstances, checks to see if a service is running and then stops it. ServiceController matchedService = //My Service! //If statements and such matchedService.Stop(); matchedService.WaitForStatus(ServiceControllerStatus.Stopped); Now, I can...

Instantiating ServiceController takes sometimes too much time

Hi, i am creating an instance of ServiceController using a remote/local machine name and the name of the service. When I type sth. like stackoverflow.com as machine name the contructor blocks for a long time and returns an exception. Example: string MachineName = "stackoverflow.com" ServiceController("RemoteRegistry", MachineName ); ...

Halt batch file until service stop is complete?

I'm using a batch file to stop a Windows service. I'm using the sc command, but I'm open to other ideas, given the question below. The problem is that the batch file proceeds while the service is stopping (the stop argument to sc seems only to request the stop -- it doesn't wait for the stop). How can I modify the batch file to not pr...

How to remotely control a Windows Service with ServiceController?

Hi, I'm trying to control Windows Services that are installed in a remote computer. I'm using the ServiceController class. I have this: ServiceController svc = new ServiceController("MyWindowsService", "COMPUTER_NAME"); With this, I can get the status of the Windows Service like this: string status = svc.Status.ToString(); But I...

ServiceController in a Windows Service

Hello, I'm trying to use ServiceController.GetServices() method to get the list of all the services. In a console application, it works OK, but I get an empty list if I call this method in a windows service. That seems an authentication issue, but I used all the account options ( Local System, Local Service, Network Service, User[which...

ServiceController permissions in Windows 7

I have an application which consists of a service and an executable. Essentially it's a forms application that is responsible for starting and stopping a service under specific circumstances. On windows XP the application manages this fine using the following code: ServiceController controller = new ServiceController(); controller.Mach...