Extracting the MSI from Java’s EXE Installer, cant be done directly. Normally we would have to run the installer, go to a temp location and copy the MSI file(s).

With this script, you can just drop the Java Offline Installer (EXE) to the SourceFiles folder, run the script, then you can find the MSI file(s) in the MSIFiles folder.


Why did i create this script?

As you may know, Java releases updates quite often. We want to keep our clients up to date for security reasons. I prefer to MSI files whenever it is possible, so that is why i always extract the MSI from the Java Offline Installer EXE file.

Another reason why i started on this script, is because i am relatively new to creating PowerShell scripts, so it was also to learn something new, and try it out.


How to use the script

Use this script on your own risk!
  1. Copy the script from below, and save it as Get-JavaMSI.ps1 in a empty folder.
  2. Run the script once, to create the folder needed. you can do so from a command line: powershell.exe -ExecutionPolicy ByPass -File Get-JavaMSI.ps1
  3. Go to java.com and download the version you wish to use. Remember to get the offline installer
  4. Save the offline installer in the SourceFiles folder, that Get-JavaMSI.ps1 created
  5. Now run the script again, like step 2.
    This time the script, will execute the installer, copy the MSI from its temp location, and paste it in the MSIFiles folder next to the SourceFiles folder. Then it will kill the java installer again.
  6. You can place more then one EXE, eg both the 32 and 64 bit version of Java, in the SourceFiles folder. It will still take both and extract them. (Remember you need to run this on a 64 bit Windows, if you want to extract the 64 bit version of Java.


Extract Java MSI from EXE with PowerShell

Save this script as Get-JavaMSI.ps1


Please feel free to comment, if you have any suggestions to the script, things i can code better or just to say hi.

I hope this was something you could use.

Thanks for reading!