Solved

starting a Windows service remotely

Posted on 2006-06-12
2
226 Views
Last Modified: 2010-04-16
Is there any way I can get a C# app to start a Windows service on another machine over the network?
0
Comment
Question by:abcast
2 Comments
 
LVL 3

Accepted Solution

by:
boethius78 earned 500 total points
ID: 16999824
Try this:

ServiceController controller = new ServiceController( "ServiceName", "MachineName" );
if( controller.Status == ServiceControllerStatus.Stopped )
    controller.Start();

I've only ever used ServiceController on the local machine though.  I guess as long as you have permission to control services on the other machine, it ought to work OK.  You'll need to add a reference to System.ServiceProcess.dll.

Hope this helps.
0
 

Author Comment

by:abcast
ID: 17050963
Thanks.  I will cache this info for later use.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question