Created
August 17, 2017 05:51
-
-
Save rako233/f7e5cd237c8903c1dd61e4506636701d to your computer and use it in GitHub Desktop.
This file contains 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
""" Change the .py file extension to point to a Python installation.""" | |
import _winreg as reg | |
import sys | |
pydir = sys.argv[1] | |
todo = [ | |
('Applications\python.exe\shell\open\command', | |
'"PYDIR\\python.exe" "%1" %*'), | |
('Applications\pythonw.exe\shell\open\command', | |
'"PYDIR\\pythonw.exe" "%1" %*'), | |
('Python.CompiledFile\DefaultIcon', | |
'PYDIR\\pyc.ico'), | |
('Python.CompiledFile\shell\open\command', | |
'"PYDIR\\python.exe" "%1" %*'), | |
('Python.File\DefaultIcon', | |
'PYDIR\\py.ico'), | |
('Python.File\shell\open\command', | |
'"PYDIR\\python.exe" "%1" %*'), | |
('Python.NoConFile\DefaultIcon', | |
'PYDIR\\py.ico'), | |
('Python.NoConFile\shell\open\command', | |
'"PYDIR\\pythonw.exe" "%1" %*'), | |
] | |
classes_root = reg.OpenKey(reg.HKEY_CLASSES_ROOT, "") | |
for path, value in todo: | |
key = reg.CreateKeyEx(classes_root, path, 0, reg.KEY_SET_VALUE) | |
reg.SetValue(key, '', reg.REG_SZ, value.replace('PYDIR', pydir)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment