ExitWindows and InitiateSystemShutdown.

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

In some cases we need to programmatically restart/shutdown a local or remote
machine. I know that there is a Windows 2000 Resource Kit that contains a
Shutdown.exe that does just this; however, we cannot get approval to
purchase the resource kit. Therefore we are looking to programmatically
shutdown/restart Windows. We've looked at ExitWindows(Ex) and
InitiateSystemShutdown(Ex). We've made sure to adjust all the priveleges
accordingliy before invoking these functions and all functions return TRUE
indicating success. The problem that we are having is that the machine
takes a long time (on the order of 30+ minutes) to shutdown/restart, or
sometimes never at all. We do not see the "It is now safe to poweroff"
screen. All we see is a blank blue screen. I have not been able to find
anything on the web that can suggest a solution. Do you have any ideas?

Thanks in advance,
Aaron W. Smith
 
John Smith said:
In some cases we need to programmatically restart/shutdown a local or remote
machine. I know that there is a Windows 2000 Resource Kit that contains a
Shutdown.exe that does just this; however, we cannot get approval to
purchase the resource kit. Therefore we are looking to programmatically
shutdown/restart Windows. We've looked at ExitWindows(Ex) and
InitiateSystemShutdown(Ex). We've made sure to adjust all the priveleges
accordingliy before invoking these functions and all functions return TRUE
indicating success. The problem that we are having is that the machine
takes a long time (on the order of 30+ minutes) to shutdown/restart, or
sometimes never at all. We do not see the "It is now safe to poweroff"
screen. All we see is a blank blue screen. I have not been able to find
anything on the web that can suggest a solution. Do you have any ideas?

Thanks in advance,
Aaron W. Smith

InitiateSystemShutdown(Ex) returns TRUE if it succeeded in starting the
shutdown, but that doesn't guarantee that the shutdown won't be aborted,
delayed, etc.

My first guess is that some process is refusing to close when it receives
the shutdown notification. You can try calling InitiateSystemShutdownEx with
the bForceAppsClosed parameter set to TRUE and seeing if that helps.

I've also seen where adjusting a service's shutdown order with
SetProcessShutdownParameters can cause problems if you cause a service to
shut down before services depending on it can close. I've only seen this
once, though.

Sean
 
Thanks Sean for the quick response. We have tried setthge the
bForceAppsClosed and TRUE and unfortunately that did not help things.
However, your second suggest about the order in which services shutdown may
have an impact. We do have a couple of services that are running that
depend on each other. We have not modified the way these shutdown via
SetProcessShutdownParameters (or any other way programmatically for that
matter.) Is Windows capable of shutting these down in a safe order or
should we look into SetProcessShutdownParameters?

Aaron W. Smith
 
Back
Top