24 lines
889 B
Python
24 lines
889 B
Python
# -*- coding: utf-8 -*-
|
|
from setuphelpers import *
|
|
import subprocess
|
|
|
|
hour_reboot = '18:00'
|
|
day_reboot = 'SUN'
|
|
|
|
def install():
|
|
pass
|
|
|
|
def audit():
|
|
if reg_key_exists(HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'):
|
|
print("Une mise à jour necéssite un redémarrage")
|
|
WAPT.write_audit_data_if_changed("Update Reboot", "Reboot Pending", reboot_pending)
|
|
run(f'schtasks /create /sc weekly /st {hour_reboot} /RU "NT AUTHORITY\SYSTEM" /d {day_reboot} /tn "Reboot_Update" /tr "shutdown /r /t 0"')
|
|
return "WARNING"
|
|
else:
|
|
print(f"Le poste n'a pas de reboot en attente.")
|
|
WAPT.write_audit_data_if_changed("Update Reboot", "Reboot Pending", reboot_pending)
|
|
if task_exists("Reboot_Update") is True:
|
|
run('schtasks /delete /tn "Reboot_Update" /f')
|
|
return "OK"
|
|
|