mirror of https://git.48k.eu/ogclient
#1065 windows: use shutdown for poweroff and reboot operations
Running ogClient as a service (non interactive user) breaks poweroff and reboot using ExitWindowsEx function in user32.dll. Spawn a subshell using os.system and use the 'shutdown' command instead. This is a terminating command, we don't need fine grain from subprocess module.more_events
parent
1601ad9b29
commit
355e6caad3
|
@ -19,10 +19,6 @@ from pystray import Icon, Menu, MenuItem
|
||||||
from src.ogRest import ThreadState
|
from src.ogRest import ThreadState
|
||||||
|
|
||||||
|
|
||||||
EWX_POWEROFF=0x00000008
|
|
||||||
EWX_REBOOT=0x00000002
|
|
||||||
|
|
||||||
|
|
||||||
def _create_default_image():
|
def _create_default_image():
|
||||||
"""
|
"""
|
||||||
Creates a default image for the tray icon. Use in case
|
Creates a default image for the tray icon. Use in case
|
||||||
|
@ -75,14 +71,12 @@ class OgWindowsOperations:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def poweroff(self):
|
def poweroff(self):
|
||||||
user32 = ctypes.WinDLL('user32')
|
|
||||||
systray_p.terminate()
|
systray_p.terminate()
|
||||||
user32.ExitWindowsEx(EWX_POWEROFF, 0x0)
|
os.system('shutdown -s -t 0')
|
||||||
|
|
||||||
def reboot(self):
|
def reboot(self):
|
||||||
user32 = ctypes.WinDLL('user32')
|
|
||||||
systray_p.terminate()
|
systray_p.terminate()
|
||||||
user32.ExitWindowsEx(EWX_REBOOT, 0x0)
|
os.system('shutdown -r -t 0')
|
||||||
|
|
||||||
def shellrun(self, request, ogRest):
|
def shellrun(self, request, ogRest):
|
||||||
cmd = request.getrun()
|
cmd = request.getrun()
|
||||||
|
|
Loading…
Reference in New Issue