【问题标题】:Run .exe using python. Wait for it to complete and then close the command prompt of that exe使用 python 运行 .exe。等待它完成,然后关闭该exe的命令提示符
【发布时间】:2019-04-30 02:30:23
【问题描述】:

如何从 python 运行 .exe,等待 .exe 完成执行,然后关闭 .exe 开始执行时打开的命令提示符。所以基本上最后我试图关闭之前打开的 .exe 文件,但只有在它完成执行之后。

os.system('C:/mybackup/imageautomation/Etl.PrepareAttachments.exe')                       
'''I want the above exe to run and after completion close itself and 
then run the exe in the below command'''
os.system('C:/mybackup/imageautomation/Etl.UploadAttachments.exe')

【问题讨论】:

  • os.system('C:/mybackup/imageautomation/Etl.PrepareAttachments.exe') 这会运行 exe,但一旦完成就不会关闭它。我必须手动关闭运行 exe 的命令提示符。
  • 如果你知道os.system那么,你为什么不试试os.system('exit')
  • @vaku 我想在第一个 exe 完成后运行另一个 exe。
  • 那么你想什么时候退出...

标签: python


【解决方案1】:

有点难,因为你没有付出你的努力,但我认为这就是你想要做的;

import sys

sys.exit()

【讨论】:

  • 我已经在上面的代码中更新了我想要做的事情。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-09
  • 1970-01-01
  • 2013-09-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-27
相关资源
最近更新 更多