In Windows 10, is it possible to make a file with a specific extension run with a given Python script? For example, I have .pickle files saved, and I wrote a simple Python script to print them out. I would like to double click on the .pickle file and have the Python script that prints it run.

I was able to create a context menu entry that successfully did this. For example, this simple Python script named view_pickle_file.py:

import pickle
import sys

filename = sys.argv[1]

var = pickle.load(open(filename, 'rb'))

if type(var) == list:
  for ii, value in enumerate(var):
    print(ii, value)
elif type(var) == dict:
  for key, val in var.items():
    print(key, val, sep="\t")
elif type(var) == set:
  for ii in var:

input("Press enter")

And the registry key at Computer\HKEY_CLASSES_ROOT\SystemFileAssociations\.pickle\shell\View\command with a (Default) REG_SZ Data value of "C:\Program Files\Python\Python38\python.exe" "C:\Scripts\Python\view_pickle_file.py" "%1":


enter image description here

which prints out the pickle file perfectly.

But this is a context menu entry. I want to double click the .pickle file to make this happen. How would I do that? Is it possible? Or is the context menu entry as close as I will ever get?

  • Try to double the back-slashes in the registry like this : `\\`.
    – harrymc
    Sep 28 '20 at 18:38
  • 1
    @harrymc, I'm not having any issues with the example I showed (the view context menu entry works correctly). The problem is that I don't know how to achieve the same thing by double clicking the file. Is there some registry manipulation I can do to achieve that?
    – jippyjoe4
    Sep 28 '20 at 20:14
  • Does your entry show up in (1) Context menu "Open with", and (2) Default Programs > Associate a file type or protocol with a program > Choose default applications by f‌ile type > .pickle ?
    – harrymc
    Sep 29 '20 at 6:41
  • @harrymc, no it does not. I assume I will need to add some different registry key to make it work by double clicking.
    – jippyjoe4
    Sep 29 '20 at 14:21

Try this registry update:

Windows Registry Editor Version 5.00


@="Pickle Document"



@="\"C:\\Program Files\\Python\\Python38\\python.exe\" \"C:\\Scripts\\Python\\view_pickle_file.py\" \"%1\""
  • Excellent! This worked great. Can you explain why the last key isn't the only one required? What's the point of the first two keys instead of just using "[HKEY_CLASSES_ROOT\pickle\shell\open\command]" for the last one?
    – jippyjoe4
    Sep 30 '20 at 14:14
  • The purpose is to set the display name for "Open with".
    – harrymc
    Sep 30 '20 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.