Extract MSI from EXE

257,748

Solution 1

Quick List: There are a number of common types of setup.exe files. Here are some of them in a "short-list". More fleshed-out details here (towards bottom).

Setup.exe Extract: (various flavors to try)

setup.exe /a
setup.exe /s /extract_all
setup.exe /s /extract_all:[path]
setup.exe /stage_only
setup.exe /extract "C:\My work"
setup.exe /x
setup.exe /x [path]
setup.exe /s /x /b"C:\FolderInWhichMSIWillBeExtracted" /v"/qn"

dark.exe -x outputfolder setup.exe

dark.exe is a WiX binary - install WiX to extract a WiX setup.exe (as of now). More (section 4).

There is always:

setup.exe /?

Temp Folder: And the last resort: launch the installer and then look for extracted files in the temp folder (more details below).

MSI Extract: msiexec.exe / File.msi extraction:

 msiexec /a File.msi
 msiexec /a File.msi TARGETDIR=C:\MyInstallPoint /qn

Many Setup Tools: It is impossible to cover all the different kinds of possible setup.exe files. They might feature all kinds of different command line switches. There are so many possible tools that can be used. (non-MSI,MSI, admin-tools, multi-platform, etc...).

NSIS / Inno: Commmon, free tools such as Inno Setup seem to make extraction hard (unofficial unpacker, not tried by me, run by virustotal.com). Whereas NSIS seems to use regular archives that standard archive software (7-zip et al) can open and extract.

General Tricks: One trick is to launch the setup.exe and look in the 1) system's temp folder for extracted files. Another trick is to use 2) 7-Zip, WinRAR, WinZip or similar archive tools to see if they can read the format. Some claim success by 3) opening the setup.exe in Visual Studio. Not a technique I use. 4) And there is obviously application repackaging - capturing the changes done to a computer after a setup has run and clean it up - requires a special tool (most of the free ones come and go, Advanced Installer Architect and AdminStudio are big players).


UPDATE: A quick presentation of various deployment tools used to create installers: How to create windows installer (comprehensive links).

And a simpler list view of the most used development tools as of now (2018), for quicker reading and overview.

And for safekeeping:


Just a disclaimer: A setup.exe file can contain an embedded MSI, it can be a legacy style (non-MSI) installer or it can be just a regular executable with no means of extraction whatsoever. The "discussion" below first presents the use of admin images for MSI files and how to extract MSI files from setup.exe files. Then it provides some links to handle other types of setup.exe files. Also see the comments section.

UPDATE: a few sections have now been added directly below, before the description of MSI file extract using administrative installation. Most significantly a blurb about extracting WiX setup.exe bundles (new kid on the block). Remember that a "last resort" to find extracted setup files, is to launch the installer and then look for extracted files in the temp folder (Hold down Windows Key, tap R, type %temp% or %tmp% and hit Enter) - try the other options first though - for reliability reasons.

Apologies for the "generalized mess" with all this heavy inter-linking. I do believe that you will find what you need if you dig enough in the links, but the content should really be cleaned up and organized better.

General links:

Extract content:

Vendor links:


WiX Toolkit & Burn Bundles (setup.exe files)

Tech Note: The WiX toolkit now delivers setup.exe files built with the bootstrapper tool Burn that you need the toolkit's own dark.exe decompiler to extract. Burn is used to build setup.exe files that can install several embedded MSI or executables in a specified sequence. Here is a sample extraction command:

dark.exe -x outputfolder MySetup.exe

Before you can run such an extraction, some prerequisite steps are required:

  1. Download and install the WiX toolkit (linking to a previous answer with some extra context information on WiX - as well as the download link).
  2. After installing WiX, just open a command prompt, CD to the folder where the setup.exe resides. Then specify the above command and press Enter
  3. The output folder will contain a couple of sub-folders containing both extracted MSI and EXE files and manifests and resource file for the Burn GUI (if any existed in the setup.exe file in the first place of course).
  4. You can now, in turn, extract the contents of the extracted MSI files (or EXE files). For an MSI that would mean running an admin install - as described below.

There is built-in MSI support for file extraction (admin install)

MSI or Windows Installer has built-in support for this - the extraction of files from an MSI file. This is called an administrative installation. It is basically intended as a way to create a network installation point from which the install can be run on many target computers. This ensures that the source files are always available for any repair operations.

Note that running an admin install versus using a zip tool to extract the files is very different! The latter will not adjust the media layout of the media table so that the package is set to use external source files - which is the correct way. Always prefer to run the actual admin install over any hacky zip extractions. As to compression, there are actually three different compression algorithms used for the cab files inside the MSI file format: MSZip, LZX, and Storing (uncompressed). All of these are handled correctly by doing an admin install.

Important: Windows Installer caches installed MSI files on the system for repair, modify and uninstall scenarios. Starting with Windows 7 (MSI version 5) the MSI files are now cached full size to avoid breaking the file signature that prevents the UAC prompt on setup launch (a known Vista problem). This may cause a tremendous increase in disk space consumption (several gigabytes for some systems). To prevent caching a huge MSI file, you should run an admin-install of the package before installing. This is how a company with proper deployment in a managed network would do things, and it will strip out the cab files and make a network install point with a small MSI file and files besides it.


Admin-installs have many uses

It is recommended to read more about admin-installs since it is a useful concept, and I have written a post on stackoverflow: What is the purpose of administrative installation initiated using msiexec /a?.

In essence the admin install is important for:

  • Extracting and inspecting the installer files
    • To get an idea of what is actually being installed and where
    • To ensure that the files look trustworthy and secure (no viruses - malware and viruses can still hide inside the MSI file though)
  • Deployment via systems management software (for example SCCM)
  • Corporate application repackaging
  • Repair, modify and self-repair operations
  • Patching & upgrades
  • MSI advertisement (among other details this involves the "run from source" feature where you can run directly from a network share and you only install shortcuts and registry data)
  • A number of other smaller details

Please read the stackoverflow post linked above for more details. It is quite an important concept for system administrators, application packagers, setup developers, release managers, and even the average user to see what they are installing etc...


Admin-install, practical how-to

You can perform an admin-install in a few different ways depending on how the installer is delivered. Essentially it is either delivered as an MSI file or wrapped in an setup.exe file.

Run these commands from an elevated command prompt, and follow the instructions in the GUI for the interactive command lines:

  • MSI files:

      msiexec /a File.msi
    

    that's to run with GUI, you can do it silently too:

      msiexec /a File.msi TARGETDIR=C:\MyInstallPoint /qn
    
  • setup.exe files:

      setup.exe /a
    

A setup.exe file can also be a legacy style setup (non-MSI) or the dreaded Installscript MSI file type - a well known buggy Installshield project type with hybrid non-standards-compliant MSI format. It is essentially an MSI with a custom, more advanced GUI, but it is also full of bugs.

For legacy setup.exe files the /a will do nothing, but you can try the /extract_all:[path] switch as explained in this pdf. It is a good reference for silent installation and other things as well. Another resource is this list of Installshield setup.exe command line parameters.

MSI patch files (*.MSP) can be applied to an admin image to properly extract its files. 7Zip will also be able to extract the files, but they will not be properly formatted.

Finally - the last resort - if no other way works, you can get hold of extracted setup files by cleaning out the temp folder on your system, launch the setup.exe interactively and then wait for the first dialog to show up. In most cases the installer will have extracted a bunch of files to a temp folder. Sometimes the files are plain, other times in CAB format, but Winzip, 7Zip or even Universal Extractor (haven't tested this product) - may be able to open these.

Solution 2

For InstallShield MSI based projects I have found the following to work:

setup.exe /s /x /b"C:\FolderInWhichMSIWillBeExtracted" /v"/qn"

This command will lead to an extracted MSI in a directory you can freely specify and a silently failed uninstall of the product.

The command line basically tells the setup.exe to attempt to uninstall the product (/x) and do so silently (/s). While doing that it should extract the MSI to a specific location (/b).

The /v command passes arguments to Windows Installer, in this case the /qn argument. The /qn argument disables any GUI output of the installer.

Solution 3

7-Zip should do the trick.

With it, you can extract all the files inside the EXE (thus, also an MSI file).

Although you can do it with 7-Zip, the better way is the administrative installation as pointed out by Stein Åsmul.

Solution 4

I'm guessing this question was mainly about InstallShield given the tags, but in case anyone comes here with the same problem for WiX-based packages (and possibly others), just call the installer with /extract, like so:

C:\> installer.exe /extract

That'll place the MSI in the folder alongside the installer.

Solution 5

Starting with parameter:

setup.exe /A

asks for saving included files (including MSI).

This may depend on the software which created the setup.exe.

Share:
257,748
emdadgar2
Author by

emdadgar2

Updated on February 27, 2020

Comments

  • emdadgar2
    emdadgar2 about 4 years

    I want to extract the MSI of an EXE setup to publish over a network.

    For example, using Universal Extractor, but it doesn't work for Java Runtime Environment.

  • diyism
    diyism over 12 years
    Then find the msi file in the system temp directory. Then msiexec /a "some_file.msi" /qb TARGETDIR="D:\some_file\"
  • m01
    m01 almost 11 years
    You could also just run echo "%TMP%" in cmd to find the temporary path, start the installer, look which directory is created in %TMP% (e.g. {A6B23C96-C53A-4A71-9B8B-73E16B680A58}), and then manually copy the files from that directory somewhere else.
  • Andriy K
    Andriy K over 10 years
    @sorin, for vc_redist there are merge modules (*.msm) that are distributed with Visual Studio
  • EdwinW
    EdwinW about 10 years
    Of all the techniques suggested, across multiple questions, this is the only one that worked for me. I'm using 'wine' on Ubuntu. The files were actually under Temp, in multiple subdirectories. It wasn't until after I had the CAB files already unpacked by the exe, that I was able to use the other tools. The command line arguments didn't do anything that I could see.
  • Stein Åsmul
    Stein Åsmul almost 10 years
    See my answer in this thread for more information on running admin installs via setup.exe /a
  • Stein Åsmul
    Stein Åsmul almost 10 years
    You will find the setup files extracted under %TMP% somewhere, the Java path stated in this question is not relevant for other installers than the Java runtime.
  • Roman Boiko
    Roman Boiko almost 10 years
    +1. Is there a website anywhere that showcases examples of excellent answers, like this one?
  • msp
    msp almost 10 years
    This solution should be upvoted! It works without extra tools, the setup.exe extracts itself! Uses a lot of undocumented options though (not shown by "setup.exe /?") According to my experiments, the /x option does not seem to be necessary.
  • Daniel Dreibrodt
    Daniel Dreibrodt over 9 years
    I added the /x option because I did not want the software installed on the system where I extract the MSI (e.g. on a build server). As the software was never installed, specifying the /x option made sure that the setup performs no actions beside extracting the MSI file. The parameters are documented at helpnet.installshield.com/installshield18helplib/…
  • msp
    msp over 9 years
    You are right about adding /x. However, as you mentioned also the /x option has side effects, namely if the product is already installed. There seems to be no way to simply extract the MSI file without side effects. Typical Microsoft: It would have been too simple if they had added an /extract option.
  • Daniel Dreibrodt
    Daniel Dreibrodt over 9 years
    This does not extract the MSI but performs an "admin install" which does not simply extract the original MSI file. The MSI in the target dir will not have the installation files compressed into it, but the installation files will be in subfolders of the target dir, which in turn are referenced by the new MSI file. Thus that MSI could not be used for easy redistribution, if that is your aim.
  • Stein Åsmul
    Stein Åsmul over 9 years
  • Stein Åsmul
    Stein Åsmul about 9 years
    Don't extract using zip for MSI files, see my answer below for more details.
  • Heath
    Heath about 8 years
    The OP was asking how to extract an MSI from an EXE which, generically, there is no unified way. It depends on the EXE and how the MSI is embedded.
  • kindall
    kindall over 7 years
    I actually just used this answer in some product documentation! I did tweak it slightly, though: setup.exe /s /bC:\msidir and then cancel the installation when the wizard appears. I prefer this because it doesn't potentially uninstall anything.
  • Luaan
    Luaan over 7 years
    @msp Microsoft makes InstallShield executables now? Interesting :) The only part that's actually a Microsoft product is the MSI file itself - the InstallShield executable is just a stupid way of extracting that MSI file and running MSIExec.
  • msp
    msp over 7 years
    @Luaan Ok, I admit I mixed the two installers up. For me, both products are just fubar sh#t. ;-)
  • andyb
    andyb about 7 years
    As others have said, using a compression utility to extract files is not the best option. Make every effort to do an 'admin install' which has many benefits.
  • Stein Åsmul
    Stein Åsmul over 6 years
    Yes, agree. Installshield setup.exe commands and Wise setup.exe commands. And Advanced Installer with setup.exe /x or setup.exe /extract There is also a "silent switch finder" but it failed a virustotal.com scan so I won't link to it.
  • Nickadiemus
    Nickadiemus over 5 years
    Is there a way to extract the files without getting the windows prompt on where to extract?
  • David Parvin
    David Parvin over 4 years
    When using this to extract my MSI, I did not get it to work when I had a trailing \ on the path. Leaving the trailing backslash off, produced my MSI just fine.
  • Nicke Manarin
    Nicke Manarin about 4 years
    The administrative install creates an almost empty MSI + a ProgramFilesFolder folder as byproduct, inside the TARGETDIR. It's not just extracting the files.