Fog Creek Software
Discussion Board




How do I run a program at Windows shutdown?

I want my utility to run at Windows shutdown.

Is this possible, without running it all the time?

If it ran all the time, it could wait for the WM_QUERYENDSESSION message, and thus detect the Windows shutdown.

But I don't want to make my users run it all the time, so I need another way to run it at Windows shutdown.

Is there such a way?

Thank you!

Crane Michael
Wednesday, July 23, 2003

For Windows NT/2000/XP, you could start with this Microsoft Knowledge Base article: http://support.microsoft.com/default.aspx?scid=kb;EN-US;322241

Philip Dickerson
Wednesday, July 23, 2003

another utility that detects windows shutdown and then runs the main one?

www.marktaw.com
Wednesday, July 23, 2003

Thank you VERY much for the useful responses!

Crane Michael
Wednesday, July 23, 2003

I'm not sure, but your last response seems sarcastic, implying that you didn't get any useful responses. If you read the Microsot KB article 322241, you will find that you can run any "script" (which includes batch files which can run a program from the command line) during system shutdown. [Note that it needs to be a program that will terminate on its own, otherwise it may prevent the system from ever shutting down.]

More details:
Click the "Start" menu button and select "Run..."
In the run dialog, type gpedit.msc and then press Enter (or click OK)
This will start the group policy editor; in this utility:
- expand "Computer Configuration"
- expand "Windows Settings"
- expand or select "Scripts(startup/shutdown)"
- double click "Shutdown"
This will open a Shutdown Properties dialog; click the "Add..." button and add your script/batch file/etc. Click OK the appropriate number of times.

If this doesn't help with what you're looking for, you need to ask more specific questions.

Philip Dickerson
Wednesday, July 23, 2003

*  Recent Topics

*  Fog Creek Home