[python-win32] Reboot apis don't work in a NT service
le.dahut at laposte.net
Fri Mar 21 17:37:27 CET 2008
With "InitiateSystemShutdown" I get :
21, "Device is not ready."
with "WTSShutdownSystem" :
1702, "The binding handle is invalid."
but even if I don't logon, it reboots after approximately 15 loops of 2
seconds but after reboot the machine is extremely slow and has a strange
"ExitWindowsEx" does its job correctly excepted that the workstation is
extremly slow and need a manual reboot to work fine...
Tim Golden wrote :
> le dahut wrote:
>> To reboot the computer I've tried this different functions :
>> win32api.ExitWindowsEx(EWX_REBOOT | EWX_FORCE)
>> win32api.InitiateSystemShutdown(None, '', 0, True, 1)
>> win32ts.WTSShutdownSystem(wts.WTS_CURRENT_SERVER_HANDLE, wts.WTS_WSD_REBOOT)
>> wa.WinExec('shutdown -r -t 0 -f')
>> I've correctly setup 'SeShutdownPrivilege' before calling them.
>> The "bForceAppsClosed" is set to True
>> Since I noticed that they didn't reboot the computer but raised an
>> error, I've put them in a loop :
>> while True:
>> except Exception, e:
>> This permits to reboot the workstation after several minutes (between 3
>> and 9 minutes).
> I'm not sure I can personally offer much here, le dahut, but
> it would help if you showed the traceback you *are* getting.
> Surely there's some clue in there which might suggest why
> you're prevented from rebooting before a delay period.
> python-win32 mailing list
> python-win32 at python.org
More information about the python-win32