How can I write values from a property into a text file within the MSI?

Article:HOWTO2896  |  Created: 2006-03-23  |  Updated: 2007-10-02  |  Article URL http://www.symantec.com/docs/HOWTO2896
Article Type
How To



Question
How can I write values from a property into a text file within the MSI?

Answer

Microsoft's Windows Installer architecture does not support writing to a text file, so this sample uses a Run WiseScript from Installation custom action. This script takes you through the steps of accepting end user input on a dialog in an .msi installation, and then creates a text file and writes the information out to a text file that it creates on the destination computer. The User Information dialog contains two edit field controls used to accept the USERNAME and COMPANYNAME properties from the end user. This sample uses the USERNAME and COMPANYNAME properties. 

This sample places the custom action used to create a WiseScript following within the MSI Script > Execute Immediate Script:

  1. Locate the RemoveExistingProduct action within the script. Highlight that area of the script and double-click on the Run WiseScript from Installation custom action.
  2. The Run WiseScript from installation dialog will appear.
  3. Click the Options button and choose Create New WiseScript. Once named and saved, WiseScript opens a blank script on the desktop.
  4. Double-click on the Get Windows Installer Property action to get the COMPANYNAME property and place it into a COMPANYNAME variable. Repeat this step for USERNAME.
  5. Select the Set Variable custom action and place it after the last Get Windows Installer Property custom action.
  6. Create a variable that will hold the path to the text file location. Enter the Variable in the Variable field and the path in the Value field.
  7. Double-click on the Insert Line into Text file action and place it after the Set Variable action. The insert Line into Text File dialog appears.
  8. Enter the variable created in step 6 enclosed in percent signs followed by a backslash and the name of the file in the File to Edit field.
  9. In the Text to Insert field, enter any information necessary to be written into the text file including the variable that contain the end user input.
  10. Enter the line number that you want this information written to. You can also choose to have it written after or before a specific line or to replace a line by populating different fields in the Insert Line into Text file action.
  11. Wrap the Run WiseScript from Installation custom action in a IF Statement so that it is only run during installation. The portion of the script should look similiar to the following:
         
          IF Installed
          Run WiseScript from Installation
          End
          RemoveExistingProduct

    Following the above steps creates a dialog that accepts end user input in an .msi installation, then writes the data collected using a WiseScript to a text file it creates on the destination computer.

Legacy ID



21033


Article URL http://www.symantec.com/docs/HOWTO2896


Terms of use for this information are found in Legal Notices