Login to participate
Endpoint Management & Virtualization BlogsRSS

Using a Property to Remove a File During Install

Eshwar's picture

During an installation, you might want to remove existing files from the destination machine. One reason to do this is to save disk space. Another reason is to avoid possible file conflicts between a previous installation and a new installation. This clean up helps prevent errors during installation.

To set up your installation to remove an existing file (such as c:\Program Files\myfile.txt) from the destination machine, follow these steps:

Create or open an installation in Wise for Windows Installer (e.g. WinZip.wsi)

  1. Go to the Components tab in Setup Editor.
  2. Add an empty component by right-clicking the Components icon and selecting New > Component
  3. In the Component Details dialog box, enter a name, such as ABC, in the Component field.
  4. Leave the remaining fields set to their default values, or set them specific to your installation. Click OK
  5. Go to the Feature tab in Setup Editor. Choose a feature to associate with this component. To ensure that this component is installed, choose a feature that is always installed.
  6. In the left pane, right-click the feature you chose and select New > Component Assignment
  7. In the Assign Components to Feature dialog box, click the name of the empty component you added in the first step. For example, click ABC. Click OK
  8. Go to the Product tab in Setup Editor
  9. Right click the Properties icon and select New > Property
  10. In the Property Settings dialog box, enter a property name, such as XYZ, in the Name field
  11. In the Value field, enter the directory path on the destination machine that contains the file you want to delete. For example c:\Program Files.
  12. Click OK
  13. Go to the Tables tab in Setup Editor.

    In the left pane, right-click RemoveFile and select New > Row to create a new row

  14. In the new row that appears in the right pane, enter the following fields:
    • FileKey: Enter any value, for example, TEST.
    • Component: From the drop-down list, select the name of the empty component that you created, such as ABC.
    • FileName: Enter the name of file you want to delete, for example, myfile.txt.
    • DirProperty: Enter the name of the property that contains the file pathname as a value, for example XYZ.
    • InstallMode: Enter one of the following (I recommend entering 3):
      • 1=Remove only when the associated component is being installed.
      • 2=Remove only when the associated component is being removed.
      • 3=Remove in either of the above cases
  15. Compile and run your installation.

    When the user runs this installation, the file c:\Program Files\myfile.txt will be removed.