How to install a msi using python script?

10,285

Solution 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

Solution 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.

Share:
10,285
Aramanethota
Author by

Aramanethota

Software Developer

Updated on June 28, 2022

Comments

  • Aramanethota
    Aramanethota almost 2 years

    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.