简体   繁体   English

如何使用python脚本安装msi?

[英]How to install a msi using python script?

Is there any python script to install a msi? 是否有任何python脚本来安装msi? I need to install msi and run it without showing any dialogue modal. 我需要安装msi并运行它而不显示任何对话模式。 I have msi on my folder c:\\user\\documents and i have a wxpython GUI developed using python script.I need to silent install msi and run the exe from the GUI. 我在我的文件夹c:\\ user \\ documents上有msi,我有一个使用python脚本开发的wxpython GUI。我需要静默安装msi并从GUI运行exe。

simple use. 简单使用。 No transforms provided, and code is non-blocking: 没有提供转换,代码是非阻塞的:

import os
os.system('msiexec /i %s /qn' % msi_location)

With transforms, and code is non-blocking: 使用转换,代码是非阻塞的:

import os
os.system('msiexec /i %s TRANSFORMS=%s /qn' % (msi_location, transforms_location)

With transforms, and code is blocking - so you know when it has completed: 使用转换,代码阻塞 - 所以你知道什么时候完成:

import subprocess
subprocess.call('msiexec /i %s TRANSFORMS=%s /qn' % (msi_location, transforms_location), shell=True)

For more info on TRANSFORMS: https://msdn.microsoft.com/en-us/library/aa367447%28v=vs.85%29.aspx 有关TRANSFORMS的更多信息: https//msdn.microsoft.com/en-us/library/aa367447%28v=vs.85%29.aspx

This is not really a python question, and it depends if your specific MSI package allow unattended installation. 这不是一个真正的python问题,它取决于您的特定MSI包是否允许无人参与安装。 See this SO article 见这篇SO文章

detect msi parameters for unattended install 检测无人参与安装的msi参数

how to find out about the parameters of an MSI package. 如何找出MSI包的参数。 Then, try the unattended installation manually using the windows command shell, calling msiexec . 然后,使用windows命令shell手动尝试无人参与安装,调用msiexec See here 看这里

http://technet.microsoft.com/en-us/library/cc759262%28v=ws.10%29.aspx http://technet.microsoft.com/en-us/library/cc759262%28v=ws.10%29.aspx

for more information. 欲获得更多信息。

Finally, all you need to do in python is to use os.system to call msiexec with the name of the package and the correct parameters. 最后,你需要在python中做的就是使用os.system来调用msiexec ,包含包的名称和正确的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM