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
Answer from Rich Tier on Stack OverflowVideos
How do I create an MSI installer for a Python application?
How do I make a Python executable?
» pip install python-msi
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
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.
Apparently casual Python installer since 3.5 has the MSIs I require embeded and they won't come out. There's however the web-installer for each Python and with that one you can do the same thing and get a working Python installation:
python-3.5.0-webinstall.exe /layout <folder>
This downloads the Release MSIs files (not Debug or PDB only). Then you'll need to filter the files that have _d.msi and _pdb.msi suffix, which is trivial with Batch now and you end up with this structure:
core.msi
dev.msi
doc.msi
exe.msi
launcher.msi
lib.msi
path.msi
pip.msi
python-3.6.0-webinstall.exe
tcltk.msi
test.msi
tools.msi
and quite a lot of VS redistributables. Depending on your needs you may want to delete .exe, .msu(redists), _d.msi, _pdb.msi files in your working directory. The rest are Release files and files that extend the interpreter functionality such as launcher(py.exe), path(probably just permanently puts python to PATH), etc.
If you run each of them with this:
msiexec.exe /a <file> targetdir=<folder>
you get a working portable Python installation. Note that such thing is not officially supported.
A sub-folder now contain all the .msi files:
https://www.python.org/ftp/python/3.8.0/amd64/
The Python MSI installer can update the system path since 2.4. Just add ADDLOCAL=ALL to the command line. You'll have to restart your system before it propagates.
msiexec /i "python-2.7.11.amd64.msi" /passive /norestart ADDLOCAL=ALL
https://www.python.org/download/releases/2.4/msi/
I have observed that on Windows 7 (Professional) with python 2.7.14 x64, no restart is required for Python to be added to PATH. Just start up a new command window after the install and python will be in the PATH.
You can determine whether or not a restart is required by the install by running the msi as follows:
start/wait "" msiexec /i "python-2.7.11.amd64.msi" /passive /norestart ADDLOCAL=ALL
if %errorlevel% == 3010 ( echo Success: reboot required ) else (if %errorlevel% == 0 ( echo Success ) else ( echo Installation failed with error code %errorlevel% ) )
That is, if %errorlevel% is 3010 (ERROR_SUCCESS_REBOOT_REQUIRED), then a reboot will be required. The use of start/wait causes cmd.exe to wait until the msiexec process finishes. This allows the msiexec return status to be available to cmd.exe.
BTW You may wish to include the option ALLUSERS=1 on the command line if you want the installation of Python to be available to all users on the system.