On Jan 2, 9:38 pm, "John Wright" <riley_wrig...@hotmail.comwrote:
Thanks. That is what I needed.
John"Tom Shelton" <tom_shel...@YOUKNOWTHEDRILLcomcast.netwrote in message
news:OP**************@TK2MSFTNGP02.phx.gbl...
On 2008-01-02, John Wright <riley_wrig...@hotmail.comwrote:
I need to know how to check the state of a windows service. I need to
determine if the windows service "Smart Card" is running. If it is not
running, I need to start the service. Also it would be nice to set it to
automatic so I wouldn't have to keep checking. Anyone know how to start
a
service from VB.NET code? I want to put the check and service activation
in
my program startup module. Thanks.
John
John,
Look at System.ServiceProcess.ServiceController, I believe it should
provide you with what you need.
--
Tom Shelton
If a sample you need then:
Add a service controller from toolbox and associate with the service
you desire.
Note that here is "myservice" is your control name and set "service
name" as "SCardSvr" for Smart Card.
If myservice.Status = ServiceProcess.ServiceControllerStatus.Stopped
Then
MsgBox("Service is NOT working, please start service",
MsgBoxStyle.Exclamation, "Warning")
ElseIf myservice.Status =
ServiceProcess.ServiceControllerStatus.Running Then
MsgBox("Service is Working!", MsgBoxStyle.Information, "Have fun")
End If
Hope this helps.