473,625 Members | 3,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows service (Restart itself)

Hello,

I have a windows service. I want to restart it after every 24 hour. Is it
possible to restart the service programmaticall y(from the service itself)
using the sercvice controller object? Or should i chose some other approach?

Any ideas?

Thanx for all help.
- Iceman
Nov 20 '05 #1
14 25110
If you don't want to get complicated, use the NT SC.EXE (service controller)
in command line mode to start your service. Set the command line for it in
the system scheduler.

-Rob Teixeira [MVP]

"iceman" <ic****@hotmail .com> wrote in message
news:eF******** ******@TK2MSFTN GP11.phx.gbl...
Hello,

I have a windows service. I want to restart it after every 24 hour. Is it
possible to restart the service programmaticall y(from the service itself)
using the sercvice controller object? Or should i chose some other approach?
Any ideas?

Thanx for all help.
- Iceman

Nov 20 '05 #2
Although you could user a ServiceControll er to stop your service, once it is
stopped it won't be able to start itself.

By far the easiest way is to have a batch file with:

net stop <servicename>
net start <servicename>

and schedule that to run once a day at the desired time of day.
"iceman" <ic****@hotmail .com> wrote in message
news:eF******** ******@TK2MSFTN GP11.phx.gbl...
Hello,

I have a windows service. I want to restart it after every 24 hour. Is it
possible to restart the service programmaticall y(from the service itself)
using the sercvice controller object? Or should i chose some other approach?
Any ideas?

Thanx for all help.
- Iceman

Nov 20 '05 #3
Cor
Hi Stephany,

Where did you be?

Cor
Nov 20 '05 #4
Been really busy the last few weeks - just finished a major overhaul of a
fairly large project.

"Cor" <no*@non.com> wrote in message
news:O2******** ******@TK2MSFTN GP10.phx.gbl...
Hi Stephany,

Where did you be?

Cor

Nov 20 '05 #5
Could i solve this issue by starting a new process(a bat file which contains
comands to stop and then start the service) from the windows service?
Is it possible?

(I have actually no control over the system schedular.)

Thanx
-Iceman

"Stephany Young" <stephany@local host> wrote in message
news:uL******** ******@TK2MSFTN GP09.phx.gbl...
Although you could user a ServiceControll er to stop your service, once it is stopped it won't be able to start itself.

By far the easiest way is to have a batch file with:

net stop <servicename>
net start <servicename>

and schedule that to run once a day at the desired time of day.
"iceman" <ic****@hotmail .com> wrote in message
news:eF******** ******@TK2MSFTN GP11.phx.gbl...
Hello,

I have a windows service. I want to restart it after every 24 hour. Is it possible to restart the service programmaticall y(from the service itself) using the sercvice controller object? Or should i chose some other

approach?

Any ideas?

Thanx for all help.
- Iceman


Nov 20 '05 #6
Could i solve this issue by starting a new process(a bat file which contains
comands to stop and then start the service) from the windows service?
Is it possible?

(I have actually no control over the system schedular.)

Thanx
-Iceman

"Rob Teixeira [MVP]" <RobTeixeira@@m sn.com> wrote in message
news:eg******** ******@TK2MSFTN GP11.phx.gbl...
If you don't want to get complicated, use the NT SC.EXE (service controller) in command line mode to start your service. Set the command line for it in
the system scheduler.

-Rob Teixeira [MVP]

"iceman" <ic****@hotmail .com> wrote in message
news:eF******** ******@TK2MSFTN GP11.phx.gbl...
Hello,

I have a windows service. I want to restart it after every 24 hour. Is it possible to restart the service programmaticall y(from the service itself) using the sercvice controller object? Or should i chose some other

approach?

Any ideas?

Thanx for all help.
- Iceman


Nov 20 '05 #7
Hi Iceman,

Why do you want to do that?
Did you get memory leaks so that you work around in this way?

If it was a COM+ service, I think you use COM+ administration library to
do the stuff.
Automating COM+ Administration
http://msdn.microsoft.com/library/de...us/cossdk/htm/
pgdeployingappl ications_5cmf.a sp

For a regular service, I think you need to use a watchdog service to do
it.(similar with the task schedule).
But you should rather fix your memory leaks.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #8
Hi Peter,

The services I am talking about is completely developed by managed code. The
reason i awant to restart the services for example each 24 hours is because
"some times" one of those services stops to do the task they was made for.
The service status is still running in the serivce control manager. When the
service is restarted then everything works fine... I am not sure why this
happens.... I have try and catch blocks "everywhere " in the code. Database
connections are Creted / Opened / Closed / Distroyed .etc.

Any ideas?

Thanx for you help and time.

Best regards
-Iceman
"Peter Huang" <v-******@online.m icrosoft.com> wrote in message
news:um******** ******@cpmsftng xa07.phx.gbl...
Hi Iceman,

Why do you want to do that?
Did you get memory leaks so that you work around in this way?

If it was a COM+ service, I think you use COM+ administration library to
do the stuff.
Automating COM+ Administration
http://msdn.microsoft.com/library/de...us/cossdk/htm/ pgdeployingappl ications_5cmf.a sp

For a regular service, I think you need to use a watchdog service to do
it.(similar with the task schedule).
But you should rather fix your memory leaks.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #9
Hi Iceman,

I think you may try to do the task in a seperate thread in which it will
signal an event to tell the service process that it was alive. If the
signal doesn't produce in a fixed period, there should be something wrong
with the working thread, you may try to Abort the thread and restart it
again.

If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #10

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

Similar topics

1
476
by: Eric Keij | last post by:
Hello, I have written a windows service in .NET which i want update. Is there an easy way to let a windows service update itself? I've written some test programs with the AppUpdater component and this is working perfect for 'normal' programs but can't be used for services. Maybe it's possible to write some modifications to the AppUpdater component to find the latest version and manually start the service?? Anybody aware of some methods...
1
1339
by: caulker | last post by:
how can a windows service terminate itself? I have a windows service that reads in configuration settings from an XML file, but I'd like the service to automatically stop if it doesn't find a particular element in the XML file.
6
3795
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
3
2287
by: Matt | last post by:
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
1
3689
by: Sergey Krutous | last post by:
Can you please help me to resolve the following issue: I developed a windows service. At start up (I have overriden OnStart method) it connects to a web service and if the connection fails the windows service sets ExitCode property to non-zero value (55) and calls Stop method. If this happens when user starts the service in Services snap-in SCM shows error massage and service stops - it's OK. I configured automatic startup and Recovery...
4
8587
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 or it will work by itself? (I'm not personally used to clusters, we need it at my office and they...
8
9803
by: =?Utf-8?B?TWlrZVo=?= | last post by:
How Can Windows Service Application Reatarts itself? Thanks.
1
2711
by: alexdrack | last post by:
Hello I'm building a windows service that grabs information from a website periodically, and the goal is to start all over again, when finding an exception, for example when internet disconnects. Any help would be appreciated. Code below public string cadena(string pagina) { try { String cadena; WebRequest myWebRequest = WebRequest.Create(pagina);
0
8637
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8358
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8502
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6119
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4090
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1504
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.