cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Pilgrim

How to get cached .msi file from self-extracting setup.exe?

I, programmatically, want to retrieve the cached .msi file from setup.exe, the same .msi file that get extracted from setup.exe to C:\Users\\AppData\Local\Temp when you double click setup.exe. However, it gets extracted to some random folder and it would be very difficult to find it (and no, clearing the Temp directory prior to running setup.exe is not an option). Running an administrative install on setup.exe (/a) is not an option because the .msi file that is extracted does not contain any of the install files. I've tried using 7za.exe but that doesn't work - it extracts the .msi file to a file called [0].

Any ideas on how to get the full msi file from setup.exe?
Labels (1)
0 Kudos
6 Replies
Highlighted
Pilgrim

Re: How to get cached .msi file from self-extracting setup.exe?

I have figured it out. 🙂 If anyone else has a need to get the full .msi file from a self-extracting setup.exe, here is what I found that works best.

1. Run the setup.exe and generate a log file and specify a language code so that the setup will get past the language dialog: setup.exe /L10133 /v"/lv MyLogFile.log"

2. The log file contains the location of the full msi file. Use grep, or some other function to search the log file for the string that starts with "******* Product:" This line contains the path to the msi file that you want. Save the path to a variable.

3. Cancel the installation: taskkill /F /IM msiexec.exe

4. Copy the .msi file to where you want it to go.

This seems to be working for me. Is it the best way to do it? Who knows. All I know is that winzip, 7za, winrar and universal extractor do not extract setup.exe's, at least ones built from basic msi projects.
0 Kudos
Highlighted
Pilgrim

Re: How to get cached .msi file from self-extracting setup.exe?

scottd72 wrote:
I have figured it out. 🙂 If anyone else has a need to get the full .msi file from a self-extracting setup.exe, here is what I found that works best.

1. Run the setup.exe and generate a log file and specify a language code so that the setup will get past the language dialog: setup.exe /L10133 /v"/lv MyLogFile.log"

2. The log file contains the location of the full msi file. Use grep, or some other function to search the log file for the string that starts with "******* Product:" This line contains the path to the msi file that you want. Save the path to a variable.

3. Cancel the installation: taskkill /F /IM msiexec.exe

4. Copy the .msi file to where you want it to go.

This seems to be working for me. Is it the best way to do it? Who knows. All I know is that winzip, 7za, winrar and universal extractor do not extract setup.exe's, at least ones built from basic msi projects.


Indeed, the setup.exe compression is proprietary.

Something that might be somewhat more simple is to just run the install silently on Win7 (MSI 5.0 caches the MSI with internal *.cabs) and use MSI API to find the name of the *.msi under c:\Windows\Installer\

You'll just need the product code to start with, and you'll be able to look it up via MsiGetProductInfo(). Then, you'll need to rename the *.msi to its original name.

No process killing, no mess.

*Something else I haven't tried myself, but the docs seem to indicate should work:

Setup.exe /b"C:\Storage\MyCachedPrograms\"
0 Kudos
Highlighted
Pilgrim

Re: How to get cached .msi file from self-extracting setup.exe?

An even better solution, in my opinion, that I just discovered. I just found that the value of the variable SourceDir in a Basic Msi project is different depending on what sequence it is accessed in. For instance, if accessed in the execution sequence the value is a subfolder under C:\Users\sod\AppData\Local\Temp. However, if accessed in the UI sequence the value is a subfolder under C:\Users\sod\AppData\Local\Downloaded Installations\!!! Win!!!

So now I create a custom action early in the UI sequence that copies the msi file from SourceDir to where ever I want it to go. And then to end the install just a simple call to abort does the job nicely. I learned that abort cleans up anything the setup installed.

I did face one problem, and that was when I called abort I would get the exit screen that required user interaction to close. Well, I just learned that running the install in "reduced UI" mode will hit the custom action in the UI sequence. setup.exe /L"1033" /V"/qr"

All I need to do is set a condition on my custom action to look for a backdoor property value and everything works.
0 Kudos
Highlighted
Pilgrim

Re: How to get cached .msi file from self-extracting setup.exe?

Cary R wrote:
Indeed, the setup.exe compression is proprietary.

Something that might be somewhat more simple is to just run the install silently on Win7 (MSI 5.0 caches the MSI with internal *.cabs) and use MSI API to find the name of the *.msi under c:\Windows\Installer\


BTW Cary, my downloaded installations don't go to c:\Windows\Installer. They all go to C:\Users\\AppData\Local\Downloaded Installations\

I think I can change it to go under c:\windows\installer - I'm not sure what the best location for them to go is.
0 Kudos
Highlighted
Pilgrim

Re: How to get cached .msi file from self-extracting setup.exe?

scottd72 wrote:
BTW Cary, my downloaded installations don't go to c:\Windows\Installer. They all go to C:\Users\\AppData\Local\Downloaded Installations\

I think I can change it to go under c:\windows\installer - I'm not sure what the best location for them to go is.


Actually, they go both places:

C:\Windows\installer is the Windows Installer cache. This always get a copy, regardless of operating system, but it's given a random name. And only on Win7 and newer, it's a full MSI copy.

"Downloaded Installations" is from a setting on the Setup.exe tab of your InstallShield release. This works too, but only if it's enabled (which it won't necessarily be for every project). You could of course just make sure to enable it for all your projects. Or you can use setup.exe /b like I mentioned, which overrides the default "Downloaded Installations" folder with one of your choosing.
0 Kudos
Highlighted
Pilgrim

Unpack MSI from setup.exe

scottd72 wrote:
BTW Cary, my downloaded installations don't go to c:\Windows\Installer. They all go to C:\Users\\AppData\Local\Downloaded Installations\

I think I can change it to go under c:\windows\installer - I'm not sure what the best location for them to go is.


A more strait forward for those on Windows 7 would be to execute the following at a command prompt.

setup.exe /extract "C:\temp\myMSI"

Which will extract the msi to the specified location.
0 Kudos