2011-10-09 83 views
0

我正在调用一个exe文件(它依赖于其他批处理文件),Python正在给出错误信息。 我能够调用exe文件(这是独立的)无法使用python调用exe文件

我在做什么是..

import os 
os.system("notepad.exe") # is working 

os.system("c:/ank.exe")  # this is giving error as ank.exe is dependent on other batch  files 
+1

什么错误?请详细说明。 –

回答

5
你必须先改变当前目录

使可执行你想运行可以找到它的依赖关系:

target = "c:/ank.exe" 
os.chdir(os.path.dirname(target)) 
os.system(target) 

否则,os.system()在运行脚本的目录中执行。

+0

我这样做仍然是os.system返回1,没有输出显示..其实我打电话给OpenEv.exe(转换为openEV批处理文件exe),路径为目标=“C:/ Program Files/FWTools2.4.7/openev.exe“和其余的步骤与你所提到的一样仍然不工作 – Vicky

相关问题