Compare commits
2
Commits
79628520b7
...
ca21b0fb3a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca21b0fb3a | ||
|
|
86224e8840 |
@@ -11,20 +11,37 @@ import os
|
||||
|
||||
uninstallkey = []
|
||||
|
||||
# Relative subdirectories under ProgramData used for this package's rollback state.
|
||||
STATE_DIRECTORY = ('Comitari', 'HardeningSafe')
|
||||
# Stores original registry values plus their package target for conditional rollback.
|
||||
STATE_FILENAME = 'original-values.json'
|
||||
|
||||
# Intentionally limited machine-wide controls. Keep state-file paths in the
|
||||
# legacy PowerShell format so existing installations can roll back safely.
|
||||
#
|
||||
# SETTINGS entry parameters:
|
||||
# Path - HKLM registry key in the format accepted by _registry_path().
|
||||
# These keys apply to the computer, rather than one signed-in user.
|
||||
# Name - exact Windows policy value name within that key.
|
||||
# Value - desired integer REG_DWORD written by _write_value().
|
||||
SETTINGS = (
|
||||
# Set the machine policy that disables AutoRun commands.
|
||||
{'Path': r'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
|
||||
'Name': 'NoAutorun', 'Value': 1},
|
||||
|
||||
# Disable AutoPlay for every drive type (0xFF mask).
|
||||
{'Path': r'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer',
|
||||
'Name': 'NoDriveTypeAutoRun', 'Value': 255},
|
||||
|
||||
# Disable AutoPlay for devices that do not expose a volume.
|
||||
{'Path': r'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer',
|
||||
'Name': 'NoAutoplayfornonVolume', 'Value': 1},
|
||||
|
||||
# Prevent use of the camera from the Windows lock screen.
|
||||
{'Path': r'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization',
|
||||
'Name': 'NoLockScreenCamera', 'Value': 1},
|
||||
|
||||
# Prevent enabling a slideshow on the Windows lock screen.
|
||||
{'Path': r'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization',
|
||||
'Name': 'NoLockScreenSlideshow', 'Value': 1},
|
||||
)
|
||||
@@ -46,10 +63,11 @@ def _read_value(path, name):
|
||||
subkey = _registry_path(path)
|
||||
if not reg_key_exists(HKEY_LOCAL_MACHINE, subkey):
|
||||
return {'Exists': False, 'Value': None}
|
||||
if not reg_value_exists(HKEY_LOCAL_MACHINE, subkey, name):
|
||||
return {'Exists': False, 'Value': None}
|
||||
missing = object()
|
||||
with reg_openkey_noredir(HKEY_LOCAL_MACHINE, subkey) as key:
|
||||
value = reg_getvalue(key, name)
|
||||
value = reg_getvalue(key, name, default=missing)
|
||||
if value is missing:
|
||||
return {'Exists': False, 'Value': None}
|
||||
if value is None:
|
||||
raise RuntimeError('Registry value disappeared while it was being read: %s' % name)
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user