#传参调用exe程序(解决相对路径,觉得路径问题),等待exe进程结束,此程序才结束。
# -*- coding: utf-8-*-
import os, os.path, sys
import win32process, win32event
exe_path = sys.argv[1]
exe_file = sys.argv[2]
#os.chdir(exe_path)
try :
handle = win32process.CreateProcess(os.path.join(exe_path, exe_file),
‘‘, None, None, 0,
win32process.CREATE_NO_WINDOW,
None ,
exe_path,
win32process.STARTUPINFO())
running = True
except Exception, e:
print "Create Error!"
handle = None
running = False
while running :
rc = win32event.WaitForSingleObject(handle[0], 1000)
if rc == win32event.WAIT_OBJECT_0:
running = False
#end while
print "GoodBye"
#需要用的模块:pywin32-214.win32-py2.5.exe
把改程序做成exe程序,就可以任何地方调用了(windows系统下)。