Skip Autologon cleanup if it wasn't used
We found in a few cases systems starting requiring logon passwords after Auto Repairs were run. Autologon might be the cause so we should avoid running it, and the cleanup, if settings are already present. Addresses issue #175
This commit is contained in:
parent
e7f6dc6b86
commit
0e124dc1f2
2 changed files with 26 additions and 21 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
"""Wizard Kit: Auto-Repair Tool"""
|
"""Wizard Kit: Auto Repair Tool"""
|
||||||
# vim: sts=2 sw=2 ts=2
|
# vim: sts=2 sw=2 ts=2
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -202,17 +202,6 @@ def build_menus(base_menus, title):
|
||||||
|
|
||||||
def end_session():
|
def end_session():
|
||||||
"""End Auto Repairs session."""
|
"""End Auto Repairs session."""
|
||||||
# Delete Auto Repairs keys
|
|
||||||
try:
|
|
||||||
reg_delete_value('HKCU', AUTO_REPAIR_KEY, 'SessionStarted')
|
|
||||||
except FileNotFoundError:
|
|
||||||
LOG.error('Ending repair session but session not started.')
|
|
||||||
try:
|
|
||||||
cmd = ['reg', 'delete', fr'HKCU\{AUTO_REPAIR_KEY}', '/f']
|
|
||||||
run_program(cmd)
|
|
||||||
except CalledProcessError:
|
|
||||||
LOG.error('Failed to remote Auto Repairs session settings')
|
|
||||||
|
|
||||||
# Remove logon task
|
# Remove logon task
|
||||||
cmd = [
|
cmd = [
|
||||||
'schtasks', '/delete', '/f',
|
'schtasks', '/delete', '/f',
|
||||||
|
|
@ -224,20 +213,26 @@ def end_session():
|
||||||
LOG.error("Failed to remove scheduled task or it doesn't exist.")
|
LOG.error("Failed to remove scheduled task or it doesn't exist.")
|
||||||
|
|
||||||
# Disable Autologon
|
# Disable Autologon
|
||||||
if is_autologon_enabled():
|
autologon_selected = reg_read_value(
|
||||||
|
'HKCU', AUTO_REPAIR_KEY, 'Use Autologon',
|
||||||
|
)
|
||||||
|
if autologon_selected and is_autologon_enabled():
|
||||||
run_tool('Sysinternals', 'Autologon', download=True)
|
run_tool('Sysinternals', 'Autologon', download=True)
|
||||||
reg_set_value(
|
reg_set_value(
|
||||||
'HKLM', r'Software\Microsoft\Windows NT\CurrentVersion\Winlogon',
|
'HKLM', r'Software\Microsoft\Windows NT\CurrentVersion\Winlogon',
|
||||||
'AutoAdminLogon', '0', 'SZ',
|
'AutoAdminLogon', '0', 'SZ',
|
||||||
)
|
)
|
||||||
reg_delete_value(
|
|
||||||
'HKLM', r'Software\Microsoft\Windows NT\CurrentVersion\Winlogon',
|
# Delete Auto Repairs keys
|
||||||
'DefaultUserName',
|
try:
|
||||||
)
|
reg_delete_value('HKCU', AUTO_REPAIR_KEY, 'SessionStarted')
|
||||||
reg_delete_value(
|
except FileNotFoundError:
|
||||||
'HKLM', r'Software\Microsoft\Windows NT\CurrentVersion\Winlogon',
|
LOG.error('Ending repair session but session not started.')
|
||||||
'DefaultDomainName',
|
try:
|
||||||
)
|
cmd = ['reg', 'delete', fr'HKCU\{AUTO_REPAIR_KEY}', '/f']
|
||||||
|
run_program(cmd)
|
||||||
|
except CalledProcessError:
|
||||||
|
LOG.error('Failed to remote Auto Repairs session settings')
|
||||||
|
|
||||||
|
|
||||||
def get_entry_settings(group, name):
|
def get_entry_settings(group, name):
|
||||||
|
|
@ -270,6 +265,12 @@ def init(menus):
|
||||||
download=True, msg_good='DONE',
|
download=True, msg_good='DONE',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Check if autologon is needed
|
||||||
|
if not session_started and is_autologon_enabled():
|
||||||
|
# Avoid running Autologon and keep current settings
|
||||||
|
menus['Options'].options['Use Autologon']['Selected'] = False
|
||||||
|
save_selection_settings(menus)
|
||||||
|
|
||||||
# Start or resume a repair session
|
# Start or resume a repair session
|
||||||
if session_started:
|
if session_started:
|
||||||
load_settings(menus)
|
load_settings(menus)
|
||||||
|
|
@ -414,6 +415,10 @@ def run_auto_repairs(base_menus):
|
||||||
save_selection_settings(menus)
|
save_selection_settings(menus)
|
||||||
print_info('Initializing...')
|
print_info('Initializing...')
|
||||||
init_run(menus['Options'].options)
|
init_run(menus['Options'].options)
|
||||||
|
reg_set_value(
|
||||||
|
'HKCU', AUTO_REPAIR_KEY, 'Use Autologon',
|
||||||
|
int(is_autologon_enabled()), 'DWORD',
|
||||||
|
)
|
||||||
if not is_autologon_enabled():
|
if not is_autologon_enabled():
|
||||||
# Either it wasn't selected or a password wasn't entered
|
# Either it wasn't selected or a password wasn't entered
|
||||||
menus['Options'].options['Use Autologon']['Selected'] = False
|
menus['Options'].options['Use Autologon']['Selected'] = False
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue