Questions tagged [servicecontroller]

104 questions
72
votes
10 answers

New Windows Service installed, fails to start: "System error 2 ... system cannot find the file specified"

I have installed several other custom .Net windows services successfully. A new one I had recently written was very similar to the others and while it installed without error - on starting it with the service controller it failed to start with the…
Ho Ho Ho
  • 1,429
  • 1
  • 10
  • 10
41
votes
7 answers

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…
lance
  • 16,092
  • 19
  • 77
  • 136
33
votes
9 answers

ServiceController seems to be unable to stop a service

I'm trying to stop a Windows service on a local machine (the service is Topshelf.Host, if that matters) with this code: serviceController.Stop(); serviceController.WaitForStatus(ServiceControllerStatus.Stopped, timeout); timeout is set to 1 hour,…
Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
21
votes
4 answers

How to remotely control a Windows Service with ServiceController?

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…
Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158
16
votes
2 answers

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…
Krishna
  • 486
  • 8
  • 20
12
votes
3 answers

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…
Matt Fellows
  • 6,512
  • 4
  • 35
  • 57
11
votes
2 answers

How do do an async ServiceController.WaitForStatus?

So ServiceController.WaitForStatus is a blocking call. How can it be done Task/Async manner?
Simon
  • 33,714
  • 21
  • 133
  • 202
7
votes
3 answers

How to stop or start Windows Service in C# mvc?

I tried System.ServiceProcess.ServiceController System.Diagnostics.Process; to control windows services in my web form. With System.ServiceProcess.ServiceController I am getting Access Denied Exception. With System.Diagnostics.Process…
Alican Uzun
  • 349
  • 1
  • 6
  • 20
7
votes
4 answers

Get Windows service start type?

In the System.ServiceProcess namespace, is there any kind of enumeration or other direct member to determine a Service's Start Type (Auto, Delayed Auto, On Demand, Disabled) of a ServiceController? The idea is to use an available member of that…
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
6
votes
2 answers

Starting remote Windows services with ServiceController and impersonation

I have a .NET MVC3 application that needs to be able to turn a remote service on and off. In order to do this I am impersonating a specific user account via WindowsIdentity.Impersonate(). To test the user's permissions I can log in as the user and…
David Brainer
  • 6,223
  • 3
  • 18
  • 16
6
votes
3 answers

Send command to service from C++

how can I send command to a Windows service from C++? Equivalent .NET code is: ServiceController sc = new ServiceController("MyService"); sc.ExecuteCommand(255);
Václav Dajbych
  • 2,584
  • 2
  • 30
  • 45
5
votes
1 answer

C# Service Status On Remote Machine

I'm an expert programmer, so therefore, I don't have a clue as to WTH I'm doing :) On a serious note; no, I'm not expert by any means. I do have a problem though, and don't know how to fix it. The good thing is, I (think I) know what the problem is,…
Jason
  • 150
  • 1
  • 1
  • 8
5
votes
7 answers

How to Debug a Windows Service

I have create a windows service using the Code Project Article. I am able to install the service and delete the service using -i and -d switch. I am able to see the service in services.msc but when I start the service it does nothing.Below I will…
Simsons
  • 12,295
  • 42
  • 153
  • 269
4
votes
2 answers

C# Query Windows Service

I have been using an application that queries Windows Services running on remote servers and writes the Machine Name, Service Name, and Status to a database. However, I want to try and capture the startup type (Automatic, Manual, Disabled) as…
Matt
  • 1,220
  • 3
  • 21
  • 36
4
votes
1 answer

.NET ServiceController.WaitForStatus ignores timeout

I've got a WinForm application and a service that does some work from the application on a server. I want the user to able to control the service from the application, so I added a ServiceController to do all the work (Start, Stop, Restart at first…
DangerousDetlef
  • 371
  • 2
  • 11
1
2 3 4 5 6 7