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.

Detect System Startup Complete


Question:

If you have a script ask for a reboot to early in the startup process, the user can be bombarded with numerous messages with logic in them like: Unable to start up as this workstation is shutting down. I would like to have a clean reboot without putting something like a 5 minute delay in my code (30 seconds is not enough, 60 seconds is sometimes too short). Does anyone have any ideas for knowing that ALL startup processes are out of the way and I can send my reboot to the system?

Answer:

Is this on the Win9x or WinNT Platform?

Is your script running *after* a logon, or is it being run via the "RunService" registry key [on Win9x] / as a native NT service [on WinNT]?

Short of having somebody logon so that "explorer.exe" is running on the system console, you're going to have some difficulty doing this 100% reliably.

On the WinNT platform, I'd suggest monitoring all services and wait for some period of time after last one in the "starting" state changes to the "started" state.

On the Win9x platform - Yuck! I'd also say wait for the WinLogon program to display the GINA logon screen [on WinNT platform] or for the Windows Logon dialog box to be displayed [on Win9x platform], but even then you have to wait for some variable amount of time after those are displayed and the time varies significantly based on the version of Windows and the applications that are installed.

Maybe monitor CPU utilization and wait until it drops down below a certain sustained average value? Even that could bite you, though.

User Reply:

This is all a Win2K/WinXP environment. The code I am launching is finalizing an installation via the RunOnce key. It is run BEFORE explorer.exe. But if it asks for a reboot at that point, the screen messages get ugly as you have conflicting actions in process (startup procedures launch as do shutdown procedures).

Your points are interesting, hopefully they can be clarified for this type of environment.

Answer:

Explorer.exe *is* the desktop shell, and it is responsible for launching *all* programs that get launched via the RunOnce registry key. So, by definition, your script is being launched by explorer.exe. However, as you've noticed, that doesn't prevent there being a conflict between your script requesting a shutdown and other programs still running and being negatively impacted by the shutdown request.

Are these other programs going to continue running, or do they end up terminating when the are complete? Maybe your script could use the process extender to count the running processes and wait until certain programs have been running for a period time while also waiting for others to have terminated. For the most part, this is going to take being familiar with the Windows configuration that you are using so that you can determine what should or shouldn't be running when the desktop is "stable".

You might also want to wait for the window named "Program Manager" to exist. This is a hidden window that explorer.exe maintains for backwards compatibility with the DDE server functionality that was supported by progman.exe. This hidden window doesn't get created until after explorer.exe has finished its initialization tasks and has actually displayed the desktop.


Article ID:   W16456
File Created: 2005:02:18:12:20:50
Last Updated: 2005:02:18:12:20:50