Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OS Reboot, Shutdown, Hibernate, Sleep, Wakeup (Windows Python)

I'm looking for an automatize way of doing Windows Power Management functions: - Reboot - Shutdown - Hibernate - Sleep - Wakeup

Is there a Python module to cover this functionality? Of course any other solutions are also appreciated...

like image 792
Azurin Avatar asked Apr 20 '10 08:04

Azurin


2 Answers

I also went with the command line:

import os
os.system(r'%windir%\system32\rundll32.exe powrprof.dll,SetSuspendState Hibernate')
like image 160
cryo Avatar answered Oct 15 '22 19:10

cryo


See win32api.ExitWindowsEx() ActiveState documentation.

for flags: http://msdn.microsoft.com/en-us/library/aa376868%28v=vs.85%29.aspx

for hybernate/sleep:
http://msdn.microsoft.com/en-us/library/aa373201%28v=vs.85%29.aspx
to use this one you need to usectypessince looks like pywin32 does not implement it.

Wakeup? I doubt you can execute code while sleeping. :)

like image 34
sherpya Avatar answered Oct 15 '22 19:10

sherpya