Click here to Skip to main content
15,908,776 members
Home / Discussions / C#
   

C#

 
AnswerRe: Can you detect if a service is running? Pin
vineas8-Aug-06 6:55
vineas8-Aug-06 6:55 
It's fairly simple to do, and you can even start it programatically if need be, here's a small snippet that starts a service not running (you'll need to add proper error checking).


string serviceName = "SomeServiceName";

ServiceController sc = new ServiceController();
sc.ServiceName = serviceName;

if (sc.Status == ServiceControllerStatus.Stopped)
{
	// Start the service, and wait until its status is "Running".
	sc.Start();
	sc.WaitForStatus(ServiceControllerStatus.Running);
}


A little more searching on the ServiceController class, and you'll see what else you can do with services.

-----
In the land of the blind, the one eyed man is king.

GeneralRe: Can you detect if a service is running? Pin
Stick^8-Aug-06 16:29
Stick^8-Aug-06 16:29 
Questioncreating hyperlink in Excel to the next Worksheet Pin
AnnnS8-Aug-06 4:14
AnnnS8-Aug-06 4:14 
QuestionHow to put checkbox in datagrid through DataGridColoumnStyle Pin
indiaone8-Aug-06 3:30
indiaone8-Aug-06 3:30 
Questionemail Pin
minniemooo8-Aug-06 3:07
minniemooo8-Aug-06 3:07 
AnswerRe: email Pin
seee sharp8-Aug-06 3:24
seee sharp8-Aug-06 3:24 
GeneralRe: email Pin
minniemooo8-Aug-06 3:41
minniemooo8-Aug-06 3:41 
GeneralRe: email Pin
Drew McGhie8-Aug-06 5:18
Drew McGhie8-Aug-06 5:18 
QuestionDataGridView - how to enter invalid data in comboboxcell Pin
anderde8-Aug-06 3:00
anderde8-Aug-06 3:00 
QuestionC#'s Form Event Question Pin
mariodai3658-Aug-06 2:17
mariodai3658-Aug-06 2:17 
AnswerRe: C#'s Form Event Question Pin
Stefan Troschuetz8-Aug-06 3:13
Stefan Troschuetz8-Aug-06 3:13 
GeneralRe: C#'s Form Event Question Pin
Robert Rohde8-Aug-06 3:21
Robert Rohde8-Aug-06 3:21 
AnswerRe: C#'s Form Event Question Pin
Drew McGhie8-Aug-06 3:20
Drew McGhie8-Aug-06 3:20 
QuestionFile name Pin
minniemooo8-Aug-06 1:55
minniemooo8-Aug-06 1:55 
AnswerRe: File name Pin
Guffa8-Aug-06 2:08
Guffa8-Aug-06 2:08 
GeneralRe: File name Pin
Drew McGhie8-Aug-06 3:25
Drew McGhie8-Aug-06 3:25 
AnswerRe: File name Pin
Stefan Troschuetz8-Aug-06 2:13
Stefan Troschuetz8-Aug-06 2:13 
QuestionSend a file directly to printer Pin
Support1238-Aug-06 1:10
Support1238-Aug-06 1:10 
AnswerRe: Send a file directly to printer Pin
stancrm8-Aug-06 1:28
stancrm8-Aug-06 1:28 
QuestionRetrive from XML Pin
Vipin Venugopal8-Aug-06 0:59
Vipin Venugopal8-Aug-06 0:59 
AnswerRe: Retrive from XML Pin
Stefan Troschuetz8-Aug-06 1:07
Stefan Troschuetz8-Aug-06 1:07 
QuestionProblems in Crystal Reports Pin
Abubakarsb8-Aug-06 0:24
Abubakarsb8-Aug-06 0:24 
QuestionSax Comm TAPI Pin
Mithun Acharya7-Aug-06 23:55
Mithun Acharya7-Aug-06 23:55 
AnswerRe: Sax Comm TAPI Pin
albCode8-Aug-06 0:20
albCode8-Aug-06 0:20 
QuestionRDP Pin
NewDev4247-Aug-06 23:48
NewDev4247-Aug-06 23:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.