I'm trying to add a context menu option for New -> Python Script on Windows 7. However, everything I've tried has failed.
The way that I thought it should work is below:
Add the following registry key:
[HKEY_CLASSES_ROOT\.py\ShellNew]
"FileName"="Template.py"
Null File version:
[HKEY_CLASSES_ROOT\.py\ShellNew]
"NullFile"=""
Optional registry key
[HKEY_CLASSES_ROOT\.py]
"PerceivedType"="text/plain"
@="Python Script"
Add the file to the Windows, ShellNew folder...
This does nothing, although I've done this before, and it worked with other file types. I'm unable to find anything for this anywhere, because they do everything I try for other file types.
What am I doing wrong?
EDIT: Python 2.7.8 or later has this option added during setup/installation.
Reference: MSDN Extending Shortcut Menus
HKEY_CLASSES_ROOT\.py\PerceivedType="text"
together with
HKEY_CLASSES_ROOT\.py\ShellNew\NullFile=""
works for me on Windows 7.
I have also set HKEY_CLASSES_ROOT\Python
default value to "Python Script"
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.py]
@="Python"
"Content Type"="text/x-python"
"Python"="Python"
"PerceivedType"="text"
[HKEY_CLASSES_ROOT\.py\ShellNew]
"NullFile"=""
[HKEY_CLASSES_ROOT\Python]
@="Python Script"
I have found that the easiest way to do this is with the following method, which I have tested on my Windows 10 PC.
- Open Regedit
- Navigate to Computer\HKEY_CLASSES_ROOT.py
- Right click on the .py key > New > Key
- Name the new key "ShellNew"
- Inside the ShellNew key, add a new string value
- Name the string value "NullFile"
- Change the NullFile's value to 1
- That's it!
(note: this should work with all plain-text file formats)
Use open++. It's easy to configure, and maybe it can do what you want.