Skip to content

Instantly share code, notes, and snippets.

@lilydjwg
Last active June 16, 2019 04:04
Show Gist options
  • Save lilydjwg/aadca1b926a78c7afef2c280c7390d4f to your computer and use it in GitHub Desktop.
Save lilydjwg/aadca1b926a78c7afef2c280c7390d4f to your computer and use it in GitHub Desktop.
cleanup HaoZip file extension registration
# 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