vpekulas
Posts: 9
Joined: Fri Jan 04, 2008 7:25 pm

Executing custom action after the files were deployed

Hello All,

I managed to trial & error my way through the AI and I've pretty much accomplished what I wanted, deployed the files to the right location, created the SQL script etc.

Now what I want to do is modify the web.config file with some basic stuff such as the APPDIR value etc.

For that I've written a vbs script that reads the config file replaces values I need it and writes it back to the config file. Example is below.

Now where would be the best place to run the script and how do I make it happen? It has to be done after it's been deployed (including the DB).

Code: Select all

Sub ModifyWebConfigFile
   Const ForReading = 1, ForWriting = 2
   Dim fso, f, ConfigFile
   Set fso = CreateObject("Scripting.FileSystemObject")
   
   ' Open the file and read it's content
   Set f = fso.OpenTextFile("Session.Property("APPDIR") & web.config", ForReading)
   ConfigFile =   f.ReadAll   
   f.Close
   
   
   ' Modify the content
   ConfigFile = Replace(ConfigFile, "Visual Basic options:", "This is a test replace.")
   

   ' Now write the modified content back to the file
   Set f = fso.OpenTextFile("Session.Property("APPDIR") & web.config", ForWriting, True)
   f.Write ConfigFile

   ' Close the file
   f.Close
End Sub
Thanks!
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
Now where would be the best place to run the script and how do I make it happen?
You can schedule the VBScript as an Attached custom action under the "InstallExecuteSequence" -> "Install" standard action in the "Custom actions" page. Also, for your custom action you will set the "Commit with no impersonation" option in the "Execution Options" section.
http://www.advancedinstaller.com/user-g ... rties.html

Since the installation properties are not available in the Commit stage, you will use the "Action Data" field (in the "Custom Action Properties" page) to pass the APPDIR property to the VBScript. This field will set the CustomActionData property which you will use in your script instead of APPDIR.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”