简体   繁体   中英

How to start a windows service from other machines?

I have some windows services writtin with C# language that is running on my machine. I also created a WPF Application to my customer start and stop theses services. When I run it on the same machine, it works fine, but when I try to run on other machines it does not work, and I got an exception with the message: Cannot open Service Control Manager on compupter 'NAME-PC'. This operation might require other privileges.

My Windows Service has a Project Installer that has a ProcessInstaller with the Account property setted to LocalSystem . I'm not sure if that influence.

How could I set the right privileges to other machines can start this service on a specific machine?

Thank you.

To assist you in some troubleshooting, as I don't think I can come up with an answer directly given your current info, first, try to change your machine name to an IP address. For example, if your WCF service is recieving the command and is trying to restart another service on that computer, then try:

string machine = "127.0.0.1";

The answer to why this would work, is I don't know. That may have something to do with the service running as a local user and has no access to your DNS to resolve a hostname.

If this does not work (or even it if does), I would attempt to set up your services using Domain accounts that are dedicated to running the service, and have been given permissions to do what you want them to. Generally, this is the best practice way of creating services that do anything, since we are not all security experts and our services might be compromised (which might be horrible when running as local system).

Also, if your service is trying to start a service on a remote machine (not local) then you will need to have some sort of network account that has permissions to do so.

I think it is a security thing.
You need to grant rights to start that service

How to grant users rights to manage services in Windows Server 2003

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM