Tuesday, July 15, 2014

Windows Tip: Adding an item to the context menu for a particular filetype

This afternoon, I set up Qt5 (or rather, PyQt5) with the Python 3 interpreter so that I could have a play around with the new stuff (e.g. integrated widgets, etc.) in QML/QtQuick 2 (which ships with Qt5). By and large though, I still want to use Python 2 for the bulk of my work for the time being, so that got me thinking about adding context menu item to all the Python files so that would run these using the newer interpreted instead.



Here's what you need to do on Windows 8 to do this:
1) Start: regedit

2) Navigate to:  HKEY_CLASSES_ROOT\Python.File\shell

3) Right-click on shell -> New Key. Call this something like "Run with Python3" (or whatever you want that command to be called in the menu

4) Right-click on the folder/key created in step 3 -> New Key. Call this "command"

5) Double-click on the "(Default)" entry under command. Enter the command to run the Python interpreter as the new value for this entry

6) Repeat the process for HKEY_CLASSES_ROOT\Python.NoConFile\shell 
     (NOTE: this step only applies when dealing with Python files. If you're doing this procedure on some other file type, replace all the "Python.blah" bits with the relevant types for the filetype you've got)


I'm just writing this down here so that I know where to look next time I need to do this :)

No comments:

Post a Comment