How to install a msi using python script?

拥有回忆 提交于 2021-02-18 16:58:27

问题


Is there any python script to install a msi? I need to install msi and run it without showing any dialogue modal. 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.


回答1:


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




回答2:


This is not really a python question, and it depends if your specific MSI package allow unattended installation. See this SO article

detect msi parameters for unattended install

how to find out about the parameters of an MSI package. Then, try the unattended installation manually using the windows command shell, calling msiexec. See here

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.



来源:https://stackoverflow.com/questions/14519958/how-to-install-a-msi-using-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!