如何在Windows中使用Python创建exe启动器

0 投票
1 回答
1855 浏览
提问于 2025-04-16 23:38

我想用一个Python脚本来启动一个exe程序,同时也希望用同一个脚本把它结束掉。

一个开始的想法是:

process = magicCommand( 'theExe.exe' ) #invoke exe

kill = 'no'
while kill == 'no':
    kill = raw_input()

otherMagicCommand( process ) #kill

编辑

这个方法在Windows上对我有效。

process = subprocess.Popen( 'theExe.exe' ) #invoke exe

kill = 'no'
while kill == 'no':
    kill = raw_input()

process.kill() #kill

1 个回答

撰写回答