Python script for win registry

This commit is contained in:
David Amrhein 2016-08-28 14:33:46 -04:00
parent 735e9195b5
commit d3807cb86c
2 changed files with 35 additions and 1 deletions

View file

@ -5,7 +5,7 @@ Windows Registry Editor Version 5.00
"URL Protocol"=""
[HKEY_CLASSES_ROOT\lbry\DefaultIcon]
@="LBRY.exe,1"
@="\"LBRY.exe,1\""
[HKEY_CLASSES_ROOT\lbry\shell]

View file

@ -0,0 +1,34 @@
import _winreg as winreg
import os
def main():
lbry_path = os.path.join(os.environ["ProgramFiles"], "LBRY", "LBRY.exe")
key_url = 'lbry'
try:
key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, key_url, 0, winreg.KEY_ALL_ACCESS)
except:
key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, key_url)
winreg.SetValueEx(key, None, 0, winreg.REG_SZ, "URL:LBRY Protocol")
winreg.SetValueEx(key, "URL Protocol", 0, winreg.REG_SZ, "")
winreg.CloseKey(key)
key_icon = os.path.join('lbry', 'DefaultIcon')
try:
key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, key_icon, 0, winreg.KEY_ALL_ACCESS)
except:
key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, key_icon)
winreg.SetValueEx(key, None, 0, winreg.REG_SZ, "\"LBRY.exe,1\"")
winreg.CloseKey(key)
key_command = os.path.join('lbry', 'shell', 'open', 'command')
try:
key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, key_command, 0, winreg.KEY_ALL_ACCESS)
except:
key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, key_command)
winreg.SetValueEx(key, None, 0, winreg.REG_SZ, "\"{0}\" \"%1\"".format(lbry_path))
winreg.CloseKey(key)
if __name__ == "__main__":
main()