cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
RICOUK
Level 4

Read data from file

Hi

We are trying to implement upgrades on our installers but we have a config file that is updated in each upgrade and it contains the connection string the user uses.

We need a way to read the data source from the connection string so that the update can copy the new config file and then the data source can be copied back into the new config file.

I can do filegrep to get the full line but I only need the value after data source, if there a way to do this with InstallScript?

Thanks in advance,
Rich
Labels (1)
0 Kudos
(8) Replies
RICOUK
Level 4

No one?

Thanks,
Rich
0 Kudos
RobertDickau
Flexera Alumni

What kind of project? What format is your config file? If it's an MSI project and an XML file, perhaps you can use a system search to get the XML data, as in the "Reading XML Data with a System Search" tip on the Tips & Tricks page (PDF warning): http://www.acresso.com/products/installation/installshield.htm?tabContent=/products/installation/installshield/res_4744.htm.
0 Kudos
RICOUK
Level 4

It is an InstallScript MSI project, the contents of the file is:





I want to search on that file for the "data source=" part and store the "localhost\sqlexpress" part in InstallShield to be used to insert into the new config file.

Thanks,
Rich
0 Kudos
RobertDickau
Flexera Alumni

One approach might be to read the whole "value" string from the XML file as in that tip; read the property value into a string with MsiGetProperty; break it apart at semicolons using StrGetTokens; then break it again at the equal sign...
0 Kudos
RICOUK
Level 4

I have done that but all I get is a null return.
Even if I try the example I get a null. If I do an install with "setup.exe /V"/L*v C:\everything.log"" (found in a post by you!) then I get the value for the example one but not mine (which leads me to the fact mine is setup wrong).
In the log it has the value changing for the example one (VALUE_FROM_XML_FILE) but does not have my one changing, the only line in the log file for mine is:
"AppSearch: Property: VALUE_FROM_CONFIG_FILE, Signature: NewSignature11"

This does not explain why it does not work on an upgrade, the purpose is for it to run on an upgrade and not on a normal install, is this not possible? If so, any other way to read the contents of an xml on an upgrade?

Thanks,
Rich

p.s. What would be the correct XPath value for my config file? I have /appsettings[@add='Main.ConnectionString'] returning "value" but that does not work.
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

RICOUK wrote:
p.s. What would be the correct XPath value for my config file? I have /appsettings[@add='Main.ConnectionString'] returning "value" but that does not work.
That XPath query refers to an appsettings element with an attribute named add with attribute value 'Main.ConnectionString'. What you probably want is /appsettings/add[@key='Main.ConnectionString'], which refers to an add element (under an appsettings element) with a key attribute as specified.
0 Kudos
RICOUK
Level 4

Thanks, but it doesn't run on an upgrade so it is pretty useless to us as we don't need it on a fresh install (as the file won't be there) is there a way to make it run on an upgrade, or write my own function that does essentially the same thing?

Someone has to have done this before, I can't see how it isn't a built in function as it seems a fairly obvious thing to me for an upgrade to do.

Thanks,
Rich
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

I believe XML changes are tied to component state changes, so what you need is to create and/or condition a component such that it will only install in the upgrade scenario. Depending on whether you mean a minor or a major upgrade, the exact approach could be rather different.

You could of course take this from a custom action approach, at which point you'll have to write similar conditions (and the whole XML update itself), but not worry about making a component only install in those certain scenarios.
0 Kudos