[python-win32] Reboot apis don't work in a NT service

le dahut 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 
behavior

"ExitWindowsEx" does its job correctly excepted that the workstation is 
extremly slow and need a manual reboot to work fine...

Klaas


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:
>>    try:
>>      wa.ExitWindowsEx(...)
>>      break
>>    except Exception, e:
>>      logging.error('%s'%e)
>>      time.sleep(0.5)
>>
>> 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.
> 
> TJG
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
> 
> 


More information about the python-win32 mailing list