menulauncher.py 704 B

123456789101112131415161718192021
  1. import json
  2. import os
  3. import subprocess
  4. current_folder_path = os.getcwd()
  5. app_name = f"{current_folder_path}\游戏文件\测试主菜单.exe"
  6. try:
  7. # 改变当前工作目录
  8. os.chdir(f"{current_folder_path}\游戏文件")
  9. # 替换为launcher.exe的路径
  10. launcher_path = app_name
  11. # 启动launcher.exe
  12. subprocess.run(f'"{launcher_path}"', encoding='utf-8', universal_newlines=True, shell=True)
  13. # app_process = subprocess.Popen([launcher_path])
  14. except FileNotFoundError:
  15. print("找不到" + app_name + ".exe,请确保它与Python脚本在同一目录下。")
  16. except Exception as e:
  17. print("运行" + app_name + "时出现错误:", e)
  18. finally:
  19. app_process = None