我尝试了很多事情,但由于某种原因我无法让事情发挥作用。我正在尝试使用 Python 脚本运行 MS VS 的 dumpbin 实用程序。
这是我尝试过的(以及对我不起作用的)
1.
tempFile = open('C:\\Windows\\temp\\tempExports.txt', 'w')
command = '"C:/Program Files/Microsoft Visual Studio 8/VC/bin/dumpbin" /EXPORTS ' + dllFilePath
process = subprocess.Popen(command, stdout=tempFile)
process.wait()
tempFile.close()
2.
tempFile = open('C:\\Windows\\temp\\tempExports.txt', 'w')
command = 'C:/Program Files/Microsoft Visual Studio 8/VC/bin/dumpbin /EXPORTS ' + dllFilePath
process = subprocess.Popen(command, stdout=tempFile)
process.wait()
tempFile.close()
3.
tempFile = open('C:\\Windows\\temp\\tempExports.txt', 'w')
process = subprocess.Popen(['C:\\Program Files\\Microsoft Visual Studio 8\\VC\\bin\\dumpbin', '/EXPORTS', dllFilePath], stdout = tempFile)
process.wait()
tempFile.close()
有谁知道做我想做的事(dumpbin /EXPORTS C:\Windows\system32\kernel32.dll > tempfile.txt
)在Python中正确吗?
论证模式为Popen需要一个非 shell 调用的字符串列表和一个 shell 调用的字符串。这很容易解决。鉴于:
>>> command = '"C:/Program Files/Microsoft Visual Studio 8/VC/bin/dumpbin" /EXPORTS ' + dllFilePath
要么打电话子进程.Popen with shell=True
:
>>> process = subprocess.Popen(command, stdout=tempFile, shell=True)
or use shlex.split创建参数列表:
>>> process = subprocess.Popen(shlex.split(command), stdout=tempFile)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)