243

We have some old patches that we want to get the files from but don't wish to spend the time installing them to a machine.

Can anyone advise a way to extract files from an MSI installation package?

Stevoisiak
  • 13,555
  • 39
  • 101
  • 154
Martin
  • 4,134
  • 6
  • 31
  • 33
  • Can you provide more information on what exact MSI installation package you want to extract, your OS details etc. – Firee Feb 07 '14 at 13:03
  • Huh, I thought you could just rename it to a .zip extension and extract directly? – Arctiic Jul 01 '22 at 22:25

15 Answers15

279

First, to access a command prompt, do this:

  1. Click the Start button.

  2. Click All Programs.

  3. Go into Accessories.

  4. Left-click on Command Prompt.

Once you have your command prompt, input the following:

msiexec /a drive:\filepath\to\MSI\file /qb TARGETDIR=drive:\filepath\to\target\folder

using the desired locations to fill the above mentioned filepaths. Example:

msiexec /a c:\testfile.msi /qb TARGETDIR=c:\temp\test
CODE-REaD
  • 445
  • 2
  • 16
  • Thanks neoice - that does seem to work, so will accept. Unfortunately it turns out they are not msi setups but installshield .exe setups. – Martin Feb 14 '09 at 12:58
  • 7
    another quick Google turned up this: http://www.legroom.net/software/uniextract I would prefer to use built-ins but it looks like an acceptable utility. –  Feb 14 '09 at 13:36
  • Note that (a) msiexec does not deal with relative filepaths and (b) will place the files into their target installation paths using this method. – Paul-Jan Feb 14 '09 at 15:46
  • 6
    As far as I understand (from msiexec /?), this command will actually install the program to that location; I don't think this is what the original requestor had in mind. –  Aug 09 '10 at 07:07
  • 1
    It appears that version 5 of msiexec will use relative paths with the TARGETDIR option. Also when testing this, my MSI was not registered in "Programs and Features", so this is actually quite useful for the purpose requested. – JoshL Jan 13 '11 at 18:07
  • Works on Windows 7 as well –  May 01 '11 at 12:22
  • 9
    @user6738 I've tested this and it does not install the software. The software is neither found in the appwiz nor can it be uninstalled via the msi and reports that it is not installed. It truly extracts the files from my test. – Adam Caviness Jan 18 '12 at 15:43
  • Can't you just unzip it? – Firee Feb 07 '14 at 13:02
  • 2
    The reference to google is... well stale since google got me here as a first hit on my search – ETL Feb 26 '14 at 20:29
  • 21
    I ran this on a locked-down Win8.1 computer (work laptop) and it should be noted that ***Admin rights are NOT needed*** to extract `.msi` files. – MattDMo Jun 02 '14 at 17:24
  • 8
    Great answer! I put this into a `extractMSI.cmd` file: `msiexec /a %1 /qb TARGETDIR="%~d1%~p1%~n1" || pause` and added it to the msi-file's "Open with..." options – Tobias Kienzler Dec 01 '14 at 11:28
  • I had a couple of msi files that I had to use /quiet instead of /qb. – Mac Nov 10 '16 at 19:19
  • 1
    FYI, this won't extract any binaries in the msi that are not installed (e.g., custom action dlls) –  Jan 11 '17 at 17:28
  • This doesn't just extract -- it RUNS the install script as well (for example try it on the nodejs msi installer) – Kraang Prime Jan 12 '17 at 14:18
  • 1
    I agree that Run as Administrator isn't required. Also the full path is required for TARGETDIR. –  Sep 07 '18 at 02:40
  • As the answer with most upvotes, this isn't all that great. it contains a lot of cruft -- the confusing "/qb" switch (in context) when there was no mention on anything about GUI, then there is the dangerous advice of running in elevated mode (including the always "helpful" "When the UAC appears, click Continue"), etc. There is at least another answer here that does a far better job at actually explaining what's going on with `msiexec`, which, frankly is _the_ preferred method of extraction, regardless. – Armen Michaeli Nov 07 '18 at 10:16
  • This copied the msi to the OUTDIR. Useless – Arrow_Raider Nov 12 '21 at 02:56
94

Use 7Zip.
It will unpack MSI , CAB, some EXE, and a lot more packages for you .There is no need for admin privileges to run this either.

-EDIT-

And its open source, so no nagging messages begging you to buy the stuff

Shekhar
  • 5,009
  • 4
  • 33
  • 49
  • 23
    and after trying it, msiexec does a better job (preserving the directories, naming files correctly, etc.) – Michael Schubert May 23 '12 at 15:44
  • This didn't seem to work for me on win7 x64 with 32-bit 7-Zip. Is there a particular way (not drag-drop) you have to tell it to open the file? – ebyrob Mar 12 '13 at 14:47
  • There should be an option of 7zip in the context menu when you right click the file - it will give you the option to extract the files – Shekhar Mar 13 '13 at 19:48
  • 8
    I see lots of stuff with an exclamation sign in front instead of actual files. I guess either something has changed or I have an odd msi file. I tried 7-Zip 9.20. – mlt Oct 01 '13 at 23:08
  • @MichaelSchubert - it depends. If you are running a non-Windows machine, 7Zip is a good option since the command-line version is available for other systems as well. Depends on the use case I'd say. – Per Lundberg May 29 '17 at 05:43
  • 1
    msiexec will properly modify the msi file's media table to use the extracted files and not the internal cabs. Always prefer using the admin install feature rather than this hacky unzipping approach. See my post below for more details. – Stein Åsmul Jul 12 '17 at 15:10
54

There is also lessmsi which is completely free and open source.

There are no advertisements or nagging messages, it will preserve directory structure and file names correctly, has a sophisticated command line interface, as well as a graphical user interface that allows browsing through the files as well as viewing internal MSI tables and other MSI attributes.

Scott Willeke
  • 675
  • 5
  • 8
  • 8
    Thanks! This one helped me to extract from an MSI which wouldn't extract with the msiexec command saying "admin install is not supported" for – axk Jan 17 '11 at 17:39
  • 1
    this one helped.. msiexec didnt extract for some reason.. – Abdul Hameed Sep 13 '19 at 10:02
  • It does not work in command-line mode, throwing `Error: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list`. – Andrew Kravchuk Jul 26 '23 at 14:26
  • @AndrewKravchuk Sorry to hear that. Please create an issue at https://github.com/activescott/lessmsi/issues with steps to reproduce the error you encountered and I'll take a look. – Scott Willeke Jul 28 '23 at 05:34
28

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.


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
  • Deployment via systems management software for example SCCM (avoids huge, cached MSI files in C:\Windows\Installer since files are extracted from internal cabs)
  • Corporate application repackaging
  • Repair, modify and self-repair operations
  • Patching & upgrades
  • MSI advertisement (the "run from source" feature)
  • 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, 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.

Stein Åsmul
  • 1,099
  • 1
  • 15
  • 25
  • Also see this answer: http://superuser.com/questions/307678/how-to-extract-files-from-msi-package/307684#307684 – Stein Åsmul Oct 10 '14 at 21:32
  • The same post on stackoverflow: http://stackoverflow.com/a/24987512/129130 (I should delete one, but both are upvoted and they were merged recently). – Stein Åsmul Oct 10 '14 at 21:33
10

I would recommend UniExtract for making neoice's solution even easier. It does the same thing, just is more automated and allows several methods for extracting MSI files, not just an administrative install (as his solution is using).

UniExtract can also handle exe's packaged with WISE or InstallShield, as well as a variety of other compressed formats. Oh, and its free.

Universal Extractor is a program do to exactly what it says: extract files from any type of archive, whether it's a simple zip file, an installation program, or even a Windows Installer (.msi) package.

Mick
  • 1,961
  • 6
  • 19
  • 22
5

If you add these registry keys, you will have an option "Extract here" when you will right click on a MSI file :

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Classes\Msi.Package\shell\ExtractHere]
@="Extract here"

[HKEY_CURRENT_USER\SOFTWARE\Classes\Msi.Package\shell\ExtractHere\command]
@="msiexec.exe /a \"%1\" TARGETDIR=\"%1_extracted\" /qb"

Save the content in a notepad file, rename the extension ".txt" to ".reg" and double-click on the file to add the keys in your registry

Christophe
  • 161
  • 1
  • 3
3

If you install Total Commander, there is a plugin to open and extract MSI files.

Manuel Ferreria
  • 348
  • 4
  • 11
1

you can use Orca this app is a part of Platform SDK, but you can also download it from here http://astebner.sts.winisp.net/Tools/Orca.zip

michael
  • 161
  • 1
  • 6
  • 3
    Orca is better for extracting meta-data like file, folder, and registry tables. It’s generally not very useful for extracting the actual files (completely useless if the files are not stored in the binary table). – Synetech Nov 08 '11 at 19:53
0

If you want to extract an MSI file, you can call the MsiInstallProductW function. I wrote an implementation in Go, just a single file 50 lines.

It is smaller than LessMsi, and its only a single Exe. Example usage:

msi-extract test.msi
Zombo
  • 1
  • 24
  • 120
  • 163
0

You can also try Heath Stewart's MSI Extractor.

0

Installshield .exe setups (as you call them) come in many flavors, and it is generally possible to extract files from them.

An Installshield setup.exe can contain old, legacy non-msi installers or new msi installers.

If the setup.exe is wrapping an MSI setup, you can specify setup.exe /a and the MSI's admin install will run, allowing you to specify and output location for the files.

If the setup.exe is a legacy Installshield setup, it may or may not support extracting files via the /extract_all:[path] switch. Please see here (updated July 2011, Acresso link was no longer valid, updated again February 2014 - pointing to itninja now).

Also note that another way to get hold of these files is to clean 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.

Stein Åsmul
  • 1,099
  • 1
  • 15
  • 25
  • My requirements for doing this have passed now - but I will try what you suggest at some point to see if it would have worked. Thanks for responding. – Martin Jul 01 '09 at 09:54
0

Try MSITOOLS.EXE hosted on InstallSite for a GUI extractor.

Shekhar
  • 5,009
  • 4
  • 33
  • 49
0

Just download Universal Extractor. It extracts all types of files, including .exe,.msi,.rar,.zip,.kgb and more.

Simon Sheehan
  • 9,114
  • 12
  • 52
  • 71
vivek
  • 9
  • 1
0

lessmsi is really the best choice here, as it offers you to choose exactly what files to extract and where they should go. In addition it can be easily installed using the apt-get framework for windows, called Choclatey. The above lessmsi website has moved and it can also be found/downloaded at GitHub. In addition you can find many other tools and MSI related information HERE. :(Sorry, I can't post more than 2 links!)

not2qubit
  • 1,993
  • 4
  • 28
  • 35
0

Add PeaZip to the list. Worked like a champ

JOpuckman
  • 109
  • 3
  • 1
    Please read [How do I recommend software](https://meta.superuser.com/questions/5329/how-do-i-recommend-software-in-my-answers/5330#5330) for some tips as to how you should go about recommending software. At the very least you should provide more than just a link, for example some additional information about the software itself, for example how it can be used to solve the problem in the question. – DavidPostill Jul 21 '15 at 22:01
  • PeaZip uses 7-zip under the hood – ManSamVampire Dec 03 '22 at 13:41