servicecontroller

New Windows Service installed, fails to start: “System error 2 … system cannot find the file specified”

旧时模样 提交于 2019-12-03 10:29:58
问题 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 error dialog: System error 2 ... system cannot find the file specified. After time and consternation, the only thing I could think of that was significantly different about this service was that the path and executable name were at least 10

New Windows Service installed, fails to start: “System error 2 … system cannot find the file specified”

╄→尐↘猪︶ㄣ 提交于 2019-12-03 01:03:01
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 error dialog: System error 2 ... system cannot find the file specified. After time and consternation, the only thing I could think of that was significantly different about this service was that the path and executable name were at least 10 characters longer than any of my other services. On shortening both the path and .exe name and re-installing,

Starting a service in ASP.NET/C# with the right permissions

故事扮演 提交于 2019-12-02 12:13:38
on my website (written in ASP.NET/C#) I want the moderaters to be able to start a certain service. The code I have for this is: ServiceController svcController = new ServiceController("InvidualFileConversion"); if (svcController != null) { try { svcController.Stop(); svcController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10)); svcController.Start(); } catch (Exception ex) { // error } } Now when I run this I get the error "Cannot open InvidualFileConversion service on computer", with the additional message: "Acces is denied". I know this is a problem with permissions

C# Service Status On Remote Machine

前提是你 提交于 2019-11-30 15:23:13
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, and I'm hoping someone here can help. Here's the synopsis of the problem. I am creating a form in C# that will do some server and database administration task for me. I have a button that when clicked is supposed to return the service status of "x" service on "y" server. The status is printed on the screen to a textbox. Here's my code: private void

How to remotely control a Windows Service with ServiceController?

元气小坏坏 提交于 2019-11-30 07:52:21
问题 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 can't control the Windows Service (by doing svc.Start(); or svc.Stop(); ). I get the following exception: Cannot open Servicexxx service on computer 'COMPUTER_NAME' That

Halt batch file until service stop is complete?

血红的双手。 提交于 2019-11-30 02:52:20
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 proceed until the stop is complete ? mdma Use can use NET stop , which is synchronous, i.e it will wait until the service stops. See - NET stop sc stop webdriveservice :loop sc query webdriveservice | find "STOPPED" if errorlevel 1 ( timeout 1 goto loop ) Jonesome

C# Service Status On Remote Machine

假如想象 提交于 2019-11-29 21:04:05
问题 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, and I'm hoping someone here can help. Here's the synopsis of the problem. I am creating a form in C# that will do some server and database administration task for me. I have a button that when clicked is supposed to return the service status of "x

Starting remote Windows services with ServiceController and impersonation

谁说胖子不能爱 提交于 2019-11-29 14:42:40
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 execute sc.exe \\[server] start [service] from the command prompt. I also know that the impersonate command is working as expected because the application runs anonymously and therefore cannot control services on my local machine ( . ) without impersonation, but can control local services with impersonation. However, when I put it together and

How to remotely control a Windows Service with ServiceController?

廉价感情. 提交于 2019-11-29 05:34:40
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 can't control the Windows Service (by doing svc.Start(); or svc.Stop(); ). I get the following exception: Cannot open Servicexxx service on computer 'COMPUTER_NAME' That's normal, I suppose there is something to do with access permissions. But how? I've looked into Google

Starting remote Windows services with ServiceController and impersonation

时光总嘲笑我的痴心妄想 提交于 2019-11-28 08:03:04
问题 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 execute sc.exe \\[server] start [service] from the command prompt. I also know that the impersonate command is working as expected because the application runs anonymously and therefore cannot control services on my local machine ( . ) without