Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run App On Windows Shutdown?

Status
Not open for further replies.

beefeater267

Programmer
Apr 6, 2005
79
Hi,

Is it possible to run a C# app on the Windows Shutdown event?

For example, i want to run my app which will kick off my virus scan before shutdown
 
I believe that Windows starts a timer on shutdown, and any applications which don't stop running within a certain time period will be killed. There are exceptions for services like WindowsUpdate, but I'm pretty sure that since it's part of the OS, you'll have a tough time integrating in with it.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
If I'm not mistaken, all open apps recieve a "WM_Close" message, which in .Net should fire the Closing() event.

Perhaps you could run a background application with just that event? From there you could do your task, or fire another app using Process.Start() etc
 
I wouldn't do this through a C# program. Create a batch file to run your soutdown task, then through Windows Group Policy set the batch file as a shutdown script.



Jeff
[purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day

"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me
 
MasterRacker,

I'm using Win XP Pro. I can't find any Windows Group Policy location in Administrative Tools.

Can this be done w/ Win XP Pro
 
Start -> Run

type in mmc

Go to File -> Add/Remove Snap in...

Click the Add button

Find Group Policy


There is no need to save your console settings once you are done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top