Friday, July 15, 2011

NSIS - How to Embed Other Installers in Your Installer

Sometimes you may want to embed some other installer in your installer. As an example if you need Java as a prerequisite then you can embed Java installation inside your installer. Then it will run the Java installation before installing your application, when you run your installer. 

So let's write a section to embed JRE installer in your installer
Section "jre" SECJRE
  File "jre-6u14-windows-i586.exe"

  DetailPrint "Starting the JRE installation"   
  ExecWait "$TEMP\jre-6u14-windows-i586.exe" 
SectionEnd

In line 2 it is checking the existence of the file "jre-6u14-windows-i586.exe". At the point of compiling NSIS script, this exe should exist in the stated relative path (in this case it should be inside the same folder as the nsis script file). In line 5 it will execute the jre installer and your installation program will be suspended until JRE installation is completed. After the JRE setup is complete it will resume the installation of your application. In this way, you can embed any number of installers inside your installer.

This can be improved in many ways. Well, before installing JRE, you can check whether JRE is already installed in the system. In that case you can consider the version too. If it is not installed then you can use the above script to install JRE. Another improvement is, instead of installing a precise JRE you can download the latest version from Internet and then install. This nsis example shows a similar thing.

4 comments:

Raj said...

thanks u for your lovely post.hope it will help me out.

also visit my blog www.ethicalstuffs.blogspot.com

Hash said...

Nice tutorial. One little thing...

Line 5 should be ExecWait "jre-6u14-windows-i586.exe"

Chuck Williams said...

Or line two should include the /oname=$TEMP\jre-6u14-windows-i586.exe option to put the JRE installer into the temp directory.

Blogger said...

Water Hack Burns 2 lb of Fat OVERNIGHT

At least 160000 men and women are hacking their diet with a easy and secret "liquid hack" to burn 2lbs every night in their sleep.

It is simple and works all the time.

Here are the easy steps for this hack:

1) Take a drinking glass and fill it half full

2) Now use this weight loss hack

and you'll become 2lbs skinnier the next day!

Related Posts with Thumbnails