InitiateSystemShutdown error 21
From: Chris Davis (Laguna.S3_at_newsgroup.nospam)
Date: 01/04/05
- Next message: Mark...: "Re: All Possible values for win32_operatingsystem objItem.Caption"
- Previous message: Chris Davis: "Re: Rebooting a PC while not logged-on"
- Next in thread: Gary Chang[MSFT]: "RE: InitiateSystemShutdown error 21"
- Reply: Gary Chang[MSFT]: "RE: InitiateSystemShutdown error 21"
- Messages sorted by: [ date ] [ thread ]
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.
- Next message: Mark...: "Re: All Possible values for win32_operatingsystem objItem.Caption"
- Previous message: Chris Davis: "Re: Rebooting a PC while not logged-on"
- Next in thread: Gary Chang[MSFT]: "RE: InitiateSystemShutdown error 21"
- Reply: Gary Chang[MSFT]: "RE: InitiateSystemShutdown error 21"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|