3

Yesterday I ran a BIOS update on a Windows7 computer. The BIOS update tool performed a shutdown of Windows and without restarting the computer (so directly after Windows shutdown), a DOS-like tool started that updated the BIOS.

I searched the WWW but all I can find is how to execute applications at Windows shutdown (so before windows goes down) or at logoff (logoff scripts).

Does anyone have any clue on how to achieve this?

huysentruitw
  • 27,376
  • 9
  • 90
  • 133

2 Answers2

1

You can run Local Group policy - gpedit.msc (From run).
Under Computer Configuration choose Windows Settings
choose Scripts(Startup/Shutdown)
On Shutdown properties you can add script and also mention parameters if needed.

enter image description here

I also advised you to look at the following question - how to delay shutdown and run a process in window service

Community
  • 1
  • 1
Dor Cohen
  • 16,769
  • 23
  • 93
  • 161
1

It is my guess that the machine had in fact performed a soft-reboot and was running BIOS code. That's the usual approach, and in some cases the soft-reboot may not be visible to the user, i.e., the BIOS self-update code may run before the POST.

However, it is (or at least used to be) possible to run Windows code post-shutdown, although obviously it is limited in what it can do. The key information can be found in the MSDN library entry on the Service Control Handler Function:

After this time expires, system shutdown proceeds regardless of whether service shutdown is complete. Note that if the system is left in the shutdown state (not restarted or powered down), the service continues to run.

So, at least in principle, all you need to do is to install a service that asks for shutdown notification but does not actually stop when shutdown occurs, and then instruct Windows to shut down without rebooting or powering off. I have actually seen this happen, but only on older versions of Windows (before automatically powering off at shutdown became the default!) so I can't guarantee that it still works, although it definitely did once.

It should, however, be noted that this will not necessarily give you the sort of environment you may be thinking of. For example, device drivers are not necessarily unloaded before shutdown; after all, what would be the point?

Harry Johnston
  • 35,639
  • 6
  • 68
  • 158
  • It's indeed possible that the tool uploaded the firmware to the BIOS and did then set a flag, so the BIOS would start an update procedure instead of the POST. I'm asking this question because we have boards with our own controllers. If we update our firmware, the controller does a hard reset, which Windows really doesn't like while it's running. Sometimes this ends up in corrupt files/registry. So we need to find a way where it is safe to have the 'plug pulled' :) – huysentruitw Sep 05 '12 at 08:49
  • The approach I've described should solve that problem, provided that the firmware update code will run properly with Windows shut down; for example, you'll (obviously!) need to load all your data from disk before starting the system shutdown. One possible alternative approach would be to reboot to an instance of Windows PE and do the firmware update from there. – Harry Johnston Sep 05 '12 at 19:25