473,568 Members | 3,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Service restart itself?

Is there an 'easy' way to have a service stop and restart itself? I
currently have a seperate service running who's job is to watch the other
service and restart it if there is a problem... can I eliminate that one and
have the service restart itself?

Thanks,

Matt
Nov 21 '05 #1
3 2283
Matt,
You can use ServiceControll er class to stop and start windows services.
Something like this

Imports System.ServiceP rocess

Dim MyController As ServiceControll er = New ServiceControll er("ServiceName ")

If MyController.Ca nStop Then
MyController.St op()
End If

Val

"Matt" wrote:
Is there an 'easy' way to have a service stop and restart itself? I
currently have a seperate service running who's job is to watch the other
service and restart it if there is a problem... can I eliminate that one and
have the service restart itself?

Thanks,

Matt

Nov 21 '05 #2
Hi Matt,

You can configure your to restart itself if an error occurs.
You can do that from the services.msc - your service - Recovery.

Br.

Kristian F. Thomsen

"Matt" <sp*****@dontgi mmespam.com> wrote in message
news:ug******** ******@TK2MSFTN GP15.phx.gbl...
Is there an 'easy' way to have a service stop and restart itself? I
currently have a seperate service running who's job is to watch the other
service and restart it if there is a problem... can I eliminate that one
and have the service restart itself?

Thanks,

Matt

Nov 21 '05 #3
Hi Kristian,

How does this work? Do I need to leave certain exceptions unhandled?

Unfortunately, one problem I am having is that the socket listener just
decides to not listen any longer, and throws no errors. I even have a timer
running and every few seconds it checks the state of the listener and the
state seems fine.

Thanks,

Matt
"Kristian F. Thomsen" <kf*@ktconsult. dk> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi Matt,

You can configure your to restart itself if an error occurs.
You can do that from the services.msc - your service - Recovery.

Br.

Kristian F. Thomsen

"Matt" <sp*****@dontgi mmespam.com> wrote in message
news:ug******** ******@TK2MSFTN GP15.phx.gbl...
Is there an 'easy' way to have a service stop and restart itself? I
currently have a seperate service running who's job is to watch the other
service and restart it if there is a problem... can I eliminate that one
and have the service restart itself?

Thanks,

Matt


Nov 21 '05 #4

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

Similar topics

14
25082
by: iceman | last post by:
Hello, I have a windows service. I want to restart it after every 24 hour. Is it possible to restart the service programmatically(from the service itself) using the sercvice controller object? Or should i chose some other approach? Any ideas? Thanx for all help. - Iceman
0
1481
by: felecha | last post by:
Is there a way to write a Service so that it will fail? I'm working on a Service written in VB.Net, that supports an application we are building, and I want to make sure that it can restart itself. This is my first experience with it. In the Service Control Manager I know there are the options to say what to do if it fails, obviously I...
6
3793
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() ServiceController.WaitForStatus(ServiceControllerStatus.Stopped) ServiceController.start() but doesn´t works. It seems waitforstatus instruction is the last
2
3514
by: Tedmond | last post by:
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
4
8583
by: ThunderMusic | last post by:
Hi, We have many servers setup as a cluster. When one server crashes, another one take the relay... We want to know if it's possible (I suppose it is) to make a Windows service developed with .NET 2.0 work in a cluster environment. I mean, how to make sure the service will take the relay if one server fails. Is there something special to do...
7
7219
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch this error. I want to restart my windows service every time the COM object throws an error. I use System.ServiceProcess.ServiceController to...
6
1333
by: A Marlow | last post by:
Hello, I am new to this game so please bear with me. I have just written a simple application as a service using Visual Studio and managed C++. I wish the process to run in the background and to not use a GUI **ever**. It just runs. And if it fails for ANY reason then it is simply to be restarted. I need some help with this please. I...
4
21696
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a webserver to see if service A needs to be updated. What service B does if it sees their is an update for service A is to download a new copy of the...
8
9795
by: =?Utf-8?B?TWlrZVo=?= | last post by:
How Can Windows Service Application Reatarts itself? Thanks.
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.