Geeks With Blogs
Jayd Page

Introduction

I recently came across a handy tool that can be used as a setup bootstrapper for windows. Its called dotNetInstaller and can be found at http://dotnetinstaller.codeplex.com/.

This tool allows the user to distribute a single compressed, executable packaged setup with all the pre-requisites. It is very customisable.

For the purposes of demonstration i will use the scenario that we encountered with our software distribution:
We have 4 pre-requisites that need to be checked and installed if the check fails. All pre-requisites must be installed before our final exe can be run.

Pre-requisites:

  1. Windows Installer 3.1
  2. Windows Imaging Component
  3. Microsoft .Net Framework 3.5 SP1
  4. Microsoft .Net Framework 4.

Steps Involved

  1. Download dotNetInstaller 2.0
  2. Create a new setup configuration
  3. Add all the necessary components, checks etc.
  4. Run a Custom Executable
  5. Build the bootstrapper.
  6. Test

1 Download dotNetInstaller 2.0

It can be downloaded at http://dotnetinstaller.codeplex.com/.
Note that at the time of this post 2.0 is in Beta testing, however it is available for download under the “Next Release” section near the bottom of the page.

2 Create a new setup configuration

  • Run the InstallerEditor.exe, located in the dotNetInstaller folder.
  • Create a new project from the File menu. File –> New.
  • Be sure to select the config file and edit the settings on the right hand side. Settings to note here would be the “log_enabled” which should be set to “True” to track the progress of your installer.
  • Add in a new setup configuration by right clicking on the “Config File” on the left hand side. Add –> Configurations –> Setup Configuration.

addconfig_thumb[4]

 

  • Select the “install”and edit the settings on the right hand side.
    • Change “APPLICATION_NAME” text to the name of your application
    • Under the “Runtime” section set the “administrator_required” to “True” (this will allow dotNetInstaller to elevate components if need be).

3 Add all the necessary components, checks etc..

  • To add a component, which would for example be a pre-requisite that needs to be installed, right click on the “install” setup configuration. Add –> Components –> Exe Component (you would choose the option that matches the type of component you want to install).
  • One Of our Components is “Windows Imaging Component”

addcomponent_thumb[2]

  • Once you have added a component select the component in the list and edit the settings on the right and side.
    • Add in names for “display_name” and “id”. (these can be the same)
    • Under the “Install” section fill in the path of the “executable”. for example "#APPPATH\presetup\wic_x86_enu.exe" /norestart /quiet
      • “#APPPATH” is the directory from which this bootstrapper will be run
      • “wic_x86_enu.exe” is the name of our Windows Imaging Component executable.
      • “/norestart /quiet” are the parameters that the executable will run with.
    • Under “Operating System” set the “os_filter_max” and “os_filter_min”
      • In our case windows imaging component will already be installed on Windows Vista and later. so we have :
        • “os_filter_max” as winServer2003Max
        • “os_filter_min” as win95
    • Set the reboot options under the “Runtime section” for this case I have set all the reboot options to “False” except for the last pre-requisite i have set the “must_reboot_required” to True. This will notify the user that they have to restart before the setup will continue.
    • Under “Return Codes”, if the pre-requisite would usually require the user to restart then put in the return code “3010” under the “returncodes_reboot” section. When the installation of this component ends, and would usually request a restart with that return code, it will now instead notify dotNetInstaller that the component was successfully installed.
  • Add in a check to the component. For many of the pre-requisite components we may want to check if they are already installed. dotNetInstaller offers many different types of checks. for the “Windows Imaging Component” we want to do a file check.
  • Right click on the “Windows Imaging Component”. Add –> Checks –> Installed Check File.
checkcomponent_thumb[3]
    • Click on the check and edit some of the properties.
      • “filename” should be where the file is located that you would like to check. in this instance “#SYSTEMPATH\WindowsCodecs.dll”
        • “#SYSTEMPATH” is the “Windows\System32” folder.
      • “comparison” allows you to specify the type of check you would like to do, “exists” or one of the version options. which would match against the “fileversion” field.
  • Once you have configured a component you can add multiple other components and checks.

4 Run a Custom Executable.

It is possible to run a custom executable / command as a component however after running the executable dotNetInstaller does not know how to evaluate that it was successfully run and execute the complete command. To circumvent this we can embed a file that will be extracted to a folder (random GUID) each time the installer runs.

  • Right click on the component for your custom executable / command. Add –> Embed –> Embedded File.

embedFile_thumb[5]

  • Set the “sourcefilepath” of your file to “#APPPATH\checkpoint.txt”. and make sure its located in the same directory as the “InstallerEditor.exe” when we create our bootstrapper
  • Once you have added an embedded file. Add in a check as we did with the “Windows Imaging Component” to check if the file exists. If this file exists then dotNetInstaller will know that your executable ran correctly.
  • Note that the path for the “filename” should be #CABPATH\checkpoint.txt (where checkpoint.txt is the name of our blank txt file that is used for checking purposes).
  • By default under the “install” –> “self-extracting CAB” – > “cab_path” will have the value of “#TEMPPATH\#GUID”. Note that this value is the value indicated by #CABPATH above.

5 Build the bootstrapper.

  • Before creating our bootstrapper executable, we should save this file as “Configuration.xml”
  • Because we want our bootstrapper to be able to resume after start-up we do not want it to run with elevated privileges by default otherwise UAC will block it from resuming on start-up.
  • By Default the executable will be compiled with a manifest that elevates the privileges to administrator. We will create and specify our own manifest.
    • Create a new .txt file and change the extension to “.manifest”. It should contain the following:
    • <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
        <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
          <security>
            <requestedPrivileges>
              <requestedExecutionLevel level="asInvoker" uiAccess="false" />
            </requestedPrivileges>
          </security>
        </trustInfo>
        <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
          <application>
            <!-- Windows Vista -->
            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
            <!-- Windows 7 -->
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
          </application>
        </compatibility>
      </assembly>

    • Notice the line
    •    <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      Here we see that the execution level has been set to “asInvoker” instead of “requireAdministrator”
  • Create an icon and a banner image (recommended size 110 X 208 px).
  • Go to File –> Create Exe you will see the following window.

createEXE_thumb[2]

  • Select the relevant files that you have created and click on “Make”

6 Test

Test your installation in a Clean Virtual Machine to ensure that you obtain the desired behaviour.

Posted on Thursday, March 31, 2011 12:03 AM | Back to top


Comments on this post: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
I was searcing for more information on how to use this program and here it is.
Thank you very much for this clear tutorial.

Do you know where I can find more information about how to use DotNetInstaller?
Left by Repacker on Jan 05, 2012 1:05 AM

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
Hi,

Please note that when you download dotNetInstaller 2.0 there is a "Doc" folder that has a dotNetInstaller.chm file in it. This file contains help on how to use the program.

Regards
Left by Jayd on Jan 07, 2012 4:57 AM

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
Hi,

I have a question concerning the Installed Check. I need to install Windows Installer 3.1, .NET 3.5 and .NET 4.0 like you, but the checks don’t work. For example for .NET 4.0, I use a check_registry_value :
Comparison = match
Defaultvalue = False
Fieldname = Installed
Fieldtype = REG_DWORD
Fieldvalue = 1
Path = SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client\Install
Rootkey = HKEY_LOCAL_MACHINE
Wowoption = NONE

But even if .NET 4.0 is already installed, the check doesn’t work. How did you do ?

If possible, I would like to have some explanations about your check_file for Windows Installer 3.1 too…

Thanks !
Left by Alyra on May 09, 2012 10:44 PM

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
Hi Alyra,

https://skydrive.live.com/?cid=3F070F6894FA2B3F&id=3F070F6894FA2B3F%21139

I have uploaded an image that displays my settings for the Windows Installer 3.1 check,
I have also uploaded an image that displays my settings for the .Net 4 check.
You can also find my configuration file that you can import into the dotnetinstaller2.0

The "Comparison" field needs to be set to "Version". Please see the images for other changes you need to make.

Regards
Left by Jayd on May 10, 2012 1:00 AM

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
It works now. Thanks a lot for the images and explanations !
Left by Alyra on May 10, 2012 6:35 PM

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
Hello Jayd,

We building a application vs.2012 using vb which will work on windows 7 (32/64bits). also we have
We want create a setup.exe which will install following components.
1)Windows Installer 4.5 (if not present)
2)net Framework 4.5 (if not present)
3)SQL CE 4.0
3)My Apps with database

Please guide us to configure the same.
Also suggest after installing using the setup.exe myapp transaction with database working fine or we need to do some changes.
Left by shirish on Mar 12, 2013 6:42 PM

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
I understood how to add the prerequisites but i wanted to know how to add different msi for different softwares.
Example i have developed addin for word, excel, powerpoint seperately(seperate msi for each) what i want is to be able to install all these three msi using one setup file all the three msi has same prerequisites.

Thanks & regards
Left by Gaurav on Jul 25, 2013 7:51 PM

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
You should be able to just add any number of msi packages after the pre-requisites.
Left by Jayd on Jul 25, 2013 8:39 PM

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
Am not able to install anything using this , I added 4 prerequisites and 2 other msi it show error for each "Failed to install contiue with next" and next also give same error
what may be the cause ??
Left by Gaurav on Jul 25, 2013 9:01 PM

# re: Configuring dotNetInstaller 2.0 to install custom prerequisites and then run a custom exe with elevated privileges.
Requesting Gravatar...
Hi, Thanks for the post. I have created a setup file with two installer. One is pre installer which create database and another install my application. It works perfectly. But the next time I run the installer I want to uncheck the checkbox of pre installer as database is already there. But the checkboxes are disabled and I can not uncheck the pre installer checkbox. Please guide.
Left by Som on Sep 11, 2013 12:56 AM

Your comment:
 (will show your gravatar)
 


Copyright © JaydPage | Powered by: GeeksWithBlogs.net | Join free