Read Configuration Parameters from Xml File

    Subject:  WiX help 
    Date:  Fri, 18 May 2007 13:06:29 -0700 (PDT) 
    Hi, 

    I am new to WiX and have just started using it for one 
    of my deployment project. Can you please let me know 
    how to set the configuration parameters to MSI from an 
    XML file. 

    For example. I am creating a network share and I want 
    the location to be provided as input but not through 
    UI. I will be passing the share location in XML file 
    and execute the MSI using that. Similary for Web sites 
    and Virtual Directories. I would like to have the 
    source code with this scenario as an example. 

    Thanks 

Currently WiX doesn't directly support this feature. But you can achieve this easily. What you need to do is write a VBS custom action to read the Xml configuration parameters and set them as MSI properties. See the customization VBS example below. Or you can simply use our free WiX tool WiXSharp.

WiX CustomAction: SetProperties.vbs

 
    Sub SetProperties 
       strXmlConfigFile = Session.Property("XMLCONFIG") 
       Set objDoc = CreateObject("msxml2.DOMDocument.3.0") 
       objDoc.Load(strXmlConfigFile) 
       Session.Property("MYFUNKYPROP") = objDoc.selectSingleNode("/root/Parameter[@name='Something']").text 
       Set objDoc = Nothing
    End Sub   
    

WiX fragment example:

    <Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi"> 
       <Fragment Id="SetProperties"> 

           <Binary Id="SETPROPERTIES" SourceFile="SetProperties.vbs" /> 
           <CustomAction Id="SetProperties" BinaryKey="SETPROPERTIES" VBScriptCall="SetProperties" Execute="immediate" /> 
           <InstallExecuteSequence> 
               <Custom Action="SetProperties" After="LaunchConditions" /> 
           </InstallExecuteSequence> 
       </Fragment> 
    </Wix> 

See also

  • Introduction to the Windows Installer XML(WiX) Toolset
  • MSI basics
  • WiX Tutorial - Steps to Create an MSI with Windows Installer XML(WiX)
  • How to Install a COM DLL with Windows Installer XML(WiX)
  • How to Add a License Agreement UI to Windows Installer XML(WiX)
  • How to Add Customization Code CustomAction to Windows Installer XML(WiX)
  • How to Reset Windows Service with Windows Installer XML(WiX)
  • How to Troubleshoot MSI Installation
  • How to Pass Parameters to the Customization Code(CustomAction)
  • How to Log Tracing Infomation to the Calling MSI from CustomAction
  • How to Invoke InstallUtil.exe to Call Your Managed Installer Class
  • How to Create a Website and Virtual Directory with Windows Installer XML(WiX)
  • How to Install Files to an Arbitrary Location Outside "Program Files"
  • How to Read Configuration Parameters from Xml File
  • How to Use Environmental Variables and WiX Preprocessor
  • Download WiXSharp



  • THIS POST IS PROVIDED "AS-IS" WITH NO WARRANTIES AND CONFERS NO RIGHTS. Build time: Sun 01/27/2008 . ©2007 Dalun Software. All rights reserved. Back to Article List