#StackBounty: #windows-10 #python #script #windows-registry #context-menu Double Click File to Run with Specific Python Script (Windows…

Bounty: 50

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 ComputerHKEY_CLASSES_ROOTSystemFileAssociations.pickleshellViewcommand with a (Default) REG_SZ Data value of "C:Program FilesPythonPython38python.exe" "C:ScriptsPythonview_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?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.