473,703 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

system shutdown check from windows service

hi,
i have a windows service that check to the external web site
httpwebresponse and save the result into log text file. and, my problem is
when i shut down my system, i also would like to save the time that i shut
down my system into that log file. but, i don't know how to do that. so,
please give me some idea or suggestion on that.

thanks,
myo zaw
Nov 30 '05 #1
3 4438
Myo Zaw wrote:
hi,
i have a windows service that check to the external web site
httpwebresponse and save the result into log text file. and, my problem is
when i shut down my system, i also would like to save the time that i shut
down my system into that log file. but, i don't know how to do that. so,
please give me some idea or suggestion on that.

thanks,
myo zaw


The simliest thing would be to use the onshutdown event in the service
to write out your log file. This won't tell you if the system is
shutting down or not so you'll get both the service stopping because of
system shutdown or user stopping the service.

Chris
Nov 30 '05 #2

"Myo Zaw" <in********@hot mail.com> wrote in message
news:u%******** ********@TK2MSF TNGP11.phx.gbl. ..
hi,
i have a windows service that check to the external web site
httpwebresponse and save the result into log text file. and, my problem is
when i shut down my system, i also would like to save the time that i shut
down my system into that log file. but, i don't know how to do that. so,
please give me some idea or suggestion on that.

thanks,
myo zaw

Override the OnShutDown event handler...
Check MSDN for ServiceBase.OnS hutDown for more info.
Willy.
Nov 30 '05 #3
thanks,
it went fine. but, one more question, i don't know why i can't access
to app.config file in my windows service. it worked fine in win32
application. i already tested with the same situation but, in my service,
the call from configurationma nager showed me that null value was return. any
idea about that?

thanks again,
myo zaw
Dec 1 '05 #4

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

Similar topics

0
1367
by: kelvlam | last post by:
I have written a service that is depending on mysqld. The service startup just fine, but I would like to have my service *always* shutdown first before mysqld does. That way I can add some log into my table before the service shutdown. As I search online, I haven't found any way to do so. Since the "service dependencies" setting of services is only used at startup stage, but not at shutdown stage. Is there any way to intercept the...
2
1860
by: Andy | last post by:
hi all, I've created a windows server that will watch to make sure another process stays running. It looks for the Process and attaches to the Exited event, which works fine. If the program is closed, my service correctly restarts it. The problem is that its working a bit too well, and it restarts the application even if the system was told to shut down. Since it
6
8759
by: carbon_dragon | last post by:
Ok, so here is the problem. I'm working on a headless server program implemented as a .NET C# Console project. There is a UPS mounted to this server (though not a windows compliant UPS). I can only talk to the UPS over a special device driver. Through this device driver I can detect that the UPS is going to notify Windows 2000 server to shut down. So I start doing a graceful termination. But Windows shuts down pretty quickly and there...
2
4586
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET Here's the scenario: 1. .NET Windows Client on a remote machine makes a web service call to update tables on a Web Server running SQL Server 2000. 2. The Update is updating about 1000 - 3000 records doing simple update statements like "Update...
6
7032
by: eroc.spam | last post by:
Hello- I'm working with a .NET windows service that can potentially take up to 10 minutes to shutdown. I would like to make it so that SCM doesn't timeout before the service actually stops, but unfortunately have not found a method that works. I've tried using ServiceBase.RequestAdditionalTime in several ways: 1) Start the shutdown process in a seperate thread in OnStop and keep requesting more time with...
6
9527
by: Ash | last post by:
Hi coders, I have a service that does alot of data copying to the database and when the service is stopped or the machine is shutting down it commits the data (in addition to other things) and makes sure it exists gracefully (this could take upto 5-6 mins). I tried increasing HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WaitToKillServiceTimeout to 5 mins (300000) on a test service that sleeps for 4 mins when OnStop/Shutdown is...
2
2565
by: Sin Jeong-hun | last post by:
I created a windows form application. It has a Threading.Timer and when the timer ticks it does some work and show a popup window. The problem is that while this program is running if the user tries to shutdown Windows, my application doesn't quit and neither does Windows. Of course, if the user first click of my application and then tries to shutdown, there is no problem. To solve this problem, I overrode WndProc of the main form,...
13
1888
by: Josť Joye | last post by:
Hello, What is the best way to stop a remoting server (Singleton SAO) that has been started with RemotingConfiguration.Configure(). For sure, I want to do this without quitting the application :-) In fact, at a given time based on an internal event, I would like to stop the remoting functionality within my process. Many thanks,
10
3247
by: tshad | last post by:
I have a Windows Service that I need to put to sleep for about 10-20 minutes. The problem is that if you try to shut it down during this time, it will tell you that the service didn't respond in time and end up in a "Stopping" state and there is nothing you can do until you reboot the system. What I did to solve the problem was just set a flag in my Shutdown method and set up a loop in my program to go to sleep for 1 minute at a time,...
0
8756
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 usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9251
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9117
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
9014
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
5922
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4429
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
4687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3122
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
2
2446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.