How do I make a executable compiled with pyinstaller find its own name? I need this to make it copy itself to startup. Or is there another way to achieve this?
file only finds the original name of the script, not the executable.
How do I make a executable compiled with pyinstaller find its own name? I need this to make it copy itself to startup. Or is there another way to achieve this?
file only finds the original name of the script, not the executable.
Hope this solves your problem
import os
import sys
# uncompiled file.py can be found by
file_name = os.path.basename(__file__)
# compiled file.exe can find itself by
file_name = os.path.basename(sys.executable)
# and path to py or exe
current_path = os.path.realpath(sys.executable)
current_path = os.path.realpath(__file__)