0
votes

I build an installer with Basic MSI Project in InstallShield 2010.

My setup has custom dialogs with inputs like textBoxes. Each TextBox has associated a variable with a default value. The package kit contain also an .xml file wich is generated by installer and has in it the values setted in wizard in a specific path. That works very well.

The problem is I have a lot of this textBoxes and a lot of steps. I want to add the possibility for a user to browse an .xml file in one of the wizard's steps and then skip all the steps to insert data in textboxes.

I guess that inside my installer's project I have to set the default values for each variables with a value or with a path (I know exactly where the value I need is in xml) in condition that the user points to an xml.

I will ignore for now if the browsed xml has not the same template I need, let's say that I will find the paths.

The question is how I set the variables in my project in case that xml file is browsed?

Latest edit:

my xml looks like:

<Settings>
    <SiteNames>
        <Setting property="prop1">value1</Setting>
        <Setting property="prop2">value2</Setting>
    </SiteNames>
</Settings>

and my .js is:

function setValues(){
    var xmlPath = Session.Property("IS_BROWSE_FILEBROWSED");
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

    xmlDoc.async = "false";
    xmlDoc.load(xmlPath);

    var elem = xmlDoc.getElementsByTagName("Setting");
    for (var i=0; i<elem.length; i++){
        Session.Property(elem[i].getAttribute("property")) = elem[i].childNodes[0].nodeValue);
    }
}

It is something wrong? my property values are not changing..

The script is running when a button is pressed. I don't know what I have to do for this to work.

Thanks for your time.

2

2 Answers

0
votes

You need a custom action that can use an XML DOM to read the XML file and call MsiSetProperty() to set your various properties.

For example:

<Settings>
  <Setting Id="SOMEPROP1">SOMEVALUE</Setting>
  <Setting Id="SOMEPROP2">SOMEVALUE</Setting>
</Setting>

Then it's just a matter of (pseudo code)

for each Setting element in Settings
  MsiSetProperty( setting.ID, setting.InnerText )
next

Also MSI's internal native UI only has a directory browser not a file browser control so you will either have to keep the filename a constant and browse the directory or work the file selection control into your custom action also.

0
votes

I give up with jscript function.. it didn't work.. I don't know why.

I use vbScript instead (is my first time :) I use vbscripts)

Dim xmlPath  
Dim xmlDoc
xmlPath = Session.Property("IS_BROWSE_FILEBROWSED")
set xmlDoc = CreateObject("Microsoft.XMLDOM")

xmlDoc.async = "false"
xmlDoc.load(xmlPath)    

for each x in xmlDoc.getElementsByTagName("Setting")           
    Session.Property(x.getAttribute("property")) = x.text
next

It works very well! Thanks for guiding me Christipher Painter!