473,508 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programmatically restart a service

Dear all,

I wrote a service by C# but I found the service is not quite stable. I want
to add some code that refresh or restart the service itself for a fixed
period. Does anyone know how to programmatically restart a service itself?
Or I need a separate process to restart my service?

Thanks for any help.

Tedmond

Nov 22 '05 #1
2 3506
Depending on the OS you are using, take a look at the service properties. In
XP there is a tab called recovery where you can define some failure and
restart properties.

Might be able to take care of your issue without writing any more code.

....but mind you this is not a solution for an unstable service. Only a
workaround.

"Tedmond" <Te*****@discussions.microsoft.com> wrote in message
news:83**********************************@microsof t.com...
Dear all,

I wrote a service by C# but I found the service is not quite stable. I
want
to add some code that refresh or restart the service itself for a fixed
period. Does anyone know how to programmatically restart a service
itself?
Or I need a separate process to restart my service?

Thanks for any help.

Tedmond

Nov 22 '05 #2
System.ServiceProcess.ServiceController class is what you want in your code
to start/stop a windows service.

"Tedmond" <Te*****@discussions.microsoft.com> wrote in message
news:83**********************************@microsof t.com...
Dear all,

I wrote a service by C# but I found the service is not quite stable. I
want
to add some code that refresh or restart the service itself for a fixed
period. Does anyone know how to programmatically restart a service
itself?
Or I need a separate process to restart my service?

Thanks for any help.

Tedmond

Nov 22 '05 #3

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

Similar topics

4
15857
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group :...
2
3434
by: John Spiegel | last post by:
Hi all, Is there a way to programmatically restart Windows (2000, specifically), login automatically then start an application? I've been running across some Windows Shell options (which...
6
3788
by: Leonardo Curros | last post by:
Hello, I would like to know what's the best way to restart one service. I would like to do it from the service itself. Is this possible? I try it with ServiceController.stop()...
8
9302
by: kenneth fleckenstein nielsen | last post by:
hi guru's I want to restart my webservice when ever it throws an exception that isn't cought. can i do that by web.config or iss or how ??
0
2186
by: Emanuele | last post by:
I have write a program using MS Visual studio C++ 7.0 (platform Windows XP professional). I'm not using .NET. This program save data in a SQL server 2000 database using ADO. Everything works...
1
2062
by: GD | last post by:
I am trying to restart IIS service programmatically from an application in the same machine. It works fine except that the "Default Web Site" in IIS Manager is not started. I wonder if there is any...
8
9785
by: =?Utf-8?B?TWlrZVo=?= | last post by:
How Can Windows Service Application Reatarts itself? Thanks.
0
970
by: svchosthunter | last post by:
I m using asp.net to search content in files with windows indexing service Once I add files in my catalog I can perform search But when ever I add new Files or change existing in catalog directory...
6
15285
by: Andrew Jocelyn | last post by:
Hi How do I programmatically change (read/write) the values in this app.config file at runtime? Specifically I want to change the client endpoint address but it would be nice to change other...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.