473,322 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Checking a Windows Service State and Starting one

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
Jan 2 '08 #1
3 3115
On 2008-01-02, John Wright <ri***********@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
Jan 2 '08 #2
Thanks. That is what I needed.

John
"Tom Shelton" <to*********@YOUKNOWTHEDRILLcomcast.netwrote in message
news:OP**************@TK2MSFTNGP02.phx.gbl...
On 2008-01-02, John Wright <ri***********@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

Jan 2 '08 #3
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.
Jan 2 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: karl | last post by:
I have a windows service that kicks off a 'monitor' thread which in turn kicks off 4 additional threads. These 4 threads basically are listen on a designated socket and report back any errors...
2
by: Razzie | last post by:
Hey all, I wrote a Windows Service. When I test it on my developement machine (winXP) it works fine. It starts ok, never crashes, etc. When I install the service on another machine (win2000) it...
5
by: Dhilip Kumar | last post by:
Hi All, I'm writing a Windows Service app using C#. I need to read some configuration settings before the service starts up. These settings will be used by the service in its operation. ...
4
by: Dao | last post by:
I have created a windows service called MyService. I followed the MSDN sample code to add the following code but it did not work. What I tried was that to start another or external program when...
3
by: BC | last post by:
Hi all, I have a windows service (on client machine) that monitors a MSMQ queue (on server machine). When a new message is in the server queue, the client windows service will get the message...
8
by: vtxr1300 | last post by:
I've followed 2 very similar tutorials on creating a windows service and an installer. But, after successfully compiling it, I try to do the InstallUtil command, but I get a...
6
by: Joe | last post by:
C# .NET 2.0 I've got a Windows Service that works exactly as I expect it to. However, it does rely on a few Configuration settings. If the customer doesn't configure it correctly, the service...
3
by: sokolo | last post by:
Hello, I wrote a windows service application however it is not working. The service is supposed to enter a new task every 5 sec within Microsoft Outlook. Here is the code for application: ...
6
by: sergio.calleja | last post by:
Hi Everybody, i need to restart a windows service made with c# when an fixed event is raised. So to test it, I've added a servicecontroller to my service, and in the creation method, i've created...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.