WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Start Program Only at Windows Shutdown


Question:

I would like to start my program only at the windows shutdown, and I would like to delay the shutdown for a ppecific amount of time to allow the complete execution of the program; is this possible?

I am running on Windows 2000 professional.

Answer:

This is done differently for different versions of windows. It actually is a very hard problem, and you only have maybe 15-20 seconds before your program is cannecelled by the system.

Take a look at:

Overview of Logon, Logoff, Startup, and Shutdown Scripts in Windows 2000
http://support.microsoft.com/?kbid=198642

How to assign scripts in Windows 2000
http://support.microsoft.com/default.aspx?scid=kb;en-us;322241&sd=tech#EDABAAA

How to assign logon, logoff, startup, and shutdown scripts using GPO.
http://support.microsoft.com/default.aspx?scid=kb;en-us;322241&sd=tech#EDABAAA

The basic operation is

  1. Create a directory off the root of C: called ShutdownNotice (C:\ShutdownNotice).

  2. Place the shutdownnotice.wbt in that directory.

  3. Run the Group Policy Editor (Start, Run, type "gpedit.msc" without the quotes and click OK). Expand Local Computer Policy, Computer Configuration, Windows Settings, and select Scripts (Startup/Shutdown).

  4. Double click on Shutdown to open the Shutdown Properties window. Select Add, then Browse. Navigate to C:\ShutdownNotice and select shutdownnotice.wbt. Click Open then click OK.

  5. You should now have a line item for the shutdownnotice.wbt file in the Shutdown Properties window. Click OK to close this window and then close the Group Policy Editor.

More:

It looks like Windows stores the script configuration in the registry(see below example) and the files are stored in C:\WINDOWS\System32\GroupPolicy\Machine\Scripts\Shutdown
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0\0]
"Script"="test.bat"
"Parameters"=""
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

Article ID:   W17023
File Created: 2007:07:03:14:27:38
Last Updated: 2007:07:03:14:27:38