InitiateSystemShutdown error 21

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Chris Davis (Laguna.S3_at_newsgroup.nospam)
Date: 01/04/05


Date: Tue, 4 Jan 2005 12:57:06 -0800

I have a custom Windows service which spawns child processes in response to
(proprietary) remote requests to perform custom tasks. In response to a
request to reboot the system, the service calls LsaLogonUser to generate a
user token for the built-in Administrator account and then
CreateProcessAsUser to spawn the child process which is supposed to perform
the actual reboot.

The child process calls OpenProcessToken, LookupPrivilegeValue, and
AdjustTokenPrivileges to enable the SE_SHUTDOWN_NAME privilege. It then calls
InitiateSystemShutdown with lpMachineName set to NULL and bForceAppsClosed
and bRebootAfterShutdown set to TRUE.

No errors are indicated from any of the Windows API functions in this
procedure except for InitiateSystemShutdown which returns error 21
(ERROR_NOT_READY) on Windows XP and Server 2003 systems when no user has
logged on. The same process works fine on Windows 2000 systems.

According to MSDN documentation for InitiateSystemShutdown:
"If the system is not ready to handle the request, the last error code is
ERROR_NOT_READY. The application should wait a short while and retry the
call."
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/initiatesystemshutdown.asp

Exactly what conditions are necessary for the system to be ready? It does
not appear to be a simple timing error since the results are consistent no
matter how long the system has been running.



Relevant Pages

  • XP hangs at boot up window after update KB 938127
    ... windows updates, XP started to hang at windows xp startup window with the ... phone then started the auto updates in mass, system again hung at start up ... request a reboot), ... (requested a reboot), and hung at same spot, restarted with commands and it ...
    (microsoft.public.windowsxp.embedded)
  • Subject: XP hangs at boot up window after update KB 938127
    ... windows updates, XP started to hang at windows xp startup window with the ... phone then started the auto updates in mass, system again hung at start up ... request a reboot), ... (requested a reboot), and hung at same spot, restarted with commands and it ...
    (microsoft.public.windowsxp.general)
  • Re: Question re installing new software on xp
    ... > I would install until that 1st reboot request and then allow the PC ... do you mean "I would NOT" install until that 1rst reboot request? ... why you would not keep installing more applications until you've satisfied ... >> I have a question regarding a fresh installation of windows xp. ...
    (microsoft.public.windowsxp.general)
  • Re: Windows Server Referral Problem
    ... EN> Markus I have a request out to Microsoft to get more information ... When Windows ... and returns a referral to the specified realm if there's a match. ... EN> I have a problem with server referrals in my Windows environment. ...
    (comp.protocols.kerberos)
  • IPSEC with certificates on Windows XP (Certificate donīt have a private key )
    ... I have a question for the Microsoft CSP and IPSEC. ... I have installed a small network of 4 computers. ... computers and two windows 2000 computers. ... The program certreq.exe generate a certificate request. ...
    (microsoft.public.platformsdk.security)