Last active
June 16, 2019 04:04
-
-
Save lilydjwg/aadca1b926a78c7afef2c280c7390d4f to your computer and use it in GitHub Desktop.
cleanup HaoZip file extension registration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: admin privileges is necessary | |
import winreg | |
i = 0 | |
while True: | |
key = winreg.EnumKey(winreg.HKEY_CLASSES_ROOT, i) | |
value = winreg.QueryValue(winreg.HKEY_CLASSES_ROOT, key) | |
if value.startswith('HaoZip.'): | |
print(f'Deleting {key} ({value})...', end='', flush=True) | |
try: | |
winreg.DeleteKey(winreg.HKEY_CLASSES_ROOT, key) | |
print('done') | |
except PermissionError: | |
key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, key, access=winreg.KEY_WRITE) | |
winreg.DeleteValue(key, None) | |
print('done with value') | |
i += 1 | |
else: | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment