I have got a scenario : 


There is a config file which the installer installs and configures the values in the files based on property variables.   


Now after installation the User might configure some settings in the config file. And it gets encrypted with few new values in the complete section. 


The issue im facing right now is during upgrade. The config file might change (New settings included in the config file) but the installer has to retain the old values in the config file and include in the new file. 


Suppose my installed file looks like : 


    <add name="test" connectionString="test" providerName="test" />



And after installation the user configurations changes the connectionstring and it gets encrypted and it looks like this: 


  <connectionStrings New_Variable="test">








So I need to update the new web.config file which is modified during next release version with these values. 


Any help would be appreciated. 




0 Comments   [ - ] Hide Comments


Please log in to comment

Answer this question or Comment on this question for clarity



Can you simply concatenate the old file contents onto the end of the new file using copy /y oldfile+newfile and have it work, or do you need to read the file in and parse it line by line looking for where to insert the current values?

Answered 07/03/2012 by: philologist
Red Belt

  • This link might help a little. http://stackoverflow.com/questions/1115508/batch-find-and-edit-lines-in-txt-file
Please log in to comment

Where is this config file residing? In AllUsersProfile?

Answered 07/03/2012 by: jagadeish
Red Belt

  • Nah copying wont help as the file is in xml format.

    And the file is installed in program files....
  • Did I ask you to copy the xml file? :)

    You can read the xml file which is residing in %ProgramFiles% and update your new xml file based on that using VBScript custom action

Please log in to comment

This is a distinctly non-trivial task.

I posted an XML class in VBS here a while ago. You could use that to read the content of the existing file into a new file, having renamed the existing one first.

Answered 07/10/2012 by: VBScab
Red Belt

Please log in to comment