Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Install Custom XML File at Runtime


4 replies to this topic

thetamind

thetamind
  • Full Members
  • 4 posts

Posted 25 January 2007 - 23:21

I'm working on a InstallScript MSI 10.5 project.

I have several available features that the user can enable/disable during install. In all cases, the application files installed are the same. The only difference is the XML configuration file. On startup, the application reads a string value from its XML config file to determine which features to show to the user.

My problem is figuring out how to install/modify the XML file based on the features selected in the installer.

InstallShield allows me to attach a component to each feature. Files can be attached to each component, such as a XML config file. This would work great if the features could only be selected exclusively. But when more than one feature is selected, two components can't install the same config file without clobbering each other.

I see I could try to use XCopyFile to copy a specific ready-made config file in script. But even with 5 feature options, the number of permutations becomes unmanageable (2^5).

Another option is to use WriteLine to output the XML file. Which encoding would it use? Currently the config file is UTF-8, but it doesn't use any exotic characters, so it might be okay to use ASCII....


Currently in the script I query which features were selected and then generate the proper config string, that should be placed in the XML config file. Now how do I get this into the XML file?

InstallShield has a XML File Edit feature. It can load strings at runtime, but only MSI Properties and the String Table. I can't find a way to update the string table at runtime. I did find a function called MSISetProperty, but it sounds more like it's designed to be used externally.

This is what I tried.

CODE
hWnd = GetWindowHandle(HWND_INSTALL);
MsiSetProperty(hWnd, "ID_INSTALL_CONFIG", sFeatures);


Then in the XML File Editor I change the correct element's value to [ID_INSTALL_CONFIG].

I haven't been able to see if this works. The installer hangs on the message "Rolling back Custom Action: XML File Changes". When I remove the XML file completely from the XML File Changes, the installer actually finishes successfully. The documentation states it needs MS XML Services 3. I'm assuming that is installed. And if it is not installed, why would the installer hang instead of throwing an error message about a missing requirement?

I also had tried pushing a value to XML File Changes by using built-in properties such as [COMPANY] or [INFOFILENAME] because those can be assigned direction in the script by using =.

So, why isn't XML File Changes allowing the install to finish? What is the best method to install a XML config file, where only one line needs to be determined at runtime?

Thanks for your help.

Edited by thetamind, 26 January 2007 - 15:29.


thetamind

thetamind
  • Full Members
  • 4 posts

Posted 06 March 2007 - 22:36

I gave up trying to get XML File Edit to work. I using CreateFile and WriteLine to manually write the XML file to disk, although I have no control over the encoding.

shankx

shankx
  • Full Members
  • 5 posts

Posted 09 July 2007 - 08:18

Use the msxml COM object to create or update an xml file

[code=auto:0]
OBJECT oXML;

szXMLFile = "File.xml";
set oXML = CreateObject("MSXML.DOMDocument");
oXML.async = FALSE;
szXpath = "/eduoem/student/class";
set oXML = CreateObject("MSXML.DOMDocument");
if (!IsObject(oXML)) then
MessageBox("Object Creation Failed",SEVERE);
endif;
try
oXML.Load(szXMLFile);
catch
nErr = Err.Number;
MessageBox(szErr + "Error 2", SEVERE);
endcatch;
listXML = ListCreate( STRINGLIST );
if (oXML.parseError.errorCode != 0) then
MessageBox("Could not open XML file " + szXMLFile + "; setup will abort.", SEVERE);
abort;
else
set objCLSNodeList = oXML.documentElement.selectNodes(szXpath);
endif;
// To do - do your xml reading here

Shiamak

Shiamak
  • Full Members
  • 6 posts

Posted 26 January 2008 - 03:43

How do you get the value of node/element using your code?

TIA

Shiamak

Shiamak
  • Full Members
  • 6 posts

Posted 27 January 2008 - 02:44

and also write them back to the original .config/xml file.