3

I'm trying to make a small Python script that is executed by clicking an option in a file's context menu. It would execute something like "path_to_script %L", where %L is (I think) the location of the file the user has right-clicked. I know I have to add something to the registry for that option to appear, but _winreg is getting confusing. What do I have to do to add a registry entry (through Python) so my script can be called like that?

1 Answer 1

1

I dont know how you can remove from registry (probably manually or _winreg) but you can follow a way like that per your custom python script to registration to windows.

registerOne.reg

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\One]
[HKEY_CLASSES_ROOT\*\shell\One\command]
@="python.exe one.py \"%1\""

one.py

def registerScriptToContextMenu ():
    # http://support.microsoft.com/kb/310516
    cmdLine = 'regedit.exe registerOne.reg'
    import os
    os.system(cmdLine)

def one_main (*args):
    pass
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.