import sys import subprocess def main(): if len(sys.argv) == 1: path = sys.argv[0] subprocess.run(['/path/to/my.exe', path]) else: print('Usage myscript.py <path>') if __name__ == "__main__": main()