A
A
Alexander2021-10-02 19:56:20
Python
Alexander, 2021-10-02 19:56:20

How to make a program installer with adding an item to the Windows context menu?

I am writing my first python script and I want to install it as a program called through the windows context menu.
Conditionally: the user launched the installer, the program was installed, an item calling the action of my script was added to the windows context menu inside the folder in which the context menu was called.
Questions:
1) What software to use to build the installer? I'm currently trying WiX Toolset, but I'm not sure if it has the required functionality.
2) How to add an item to the Windows context menu to the process of creating an installation file?
3) How to make sure that the script is called exactly in the folder where there will be a click in the context menu?
The current view of the script (at the moment the functionality itself is not finished):

import os

def getFilenameWithoutExtension (someFilename):
    filename, file_extension = os.path.splitext(someFilename)
    return filename

def getSingles():
    files = list(filter(os.path.isfile, os.listdir()))
    singles = []
    for file in files:
        matchCount = 0
        filenameWithoutExtension = getFilenameWithoutExtension(file)
        for anotherFile in files:
            if file != anotherFile:
                anotherFileWithoutExtension = getFilenameWithoutExtension(anotherFile)
                if filenameWithoutExtension == anotherFileWithoutExtension :
                    matchCount += 1
        if matchCount == 0 :
            singles.append(file)
    return singles

print('Все файлы: ', os.listdir())
print('Одиночные файлы: ', getSingles())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2021-10-02
@saimon108

1) You can use NSIS
2) https://stackoverflow.com/a/29769228 Adding a key to the registry via NSIS https://nsis.sourceforge.io/Reading_and_Writing_th...
3) You can try to do it like here https://stackoverflow .com/a/60977397
How to parse arguments in Python - described here https://docs.python.org/3/library/argparse.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question