cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Deleting a File or Folder During Install or Uninstall

Deleting a File or Folder During Install or Uninstall

Summary

This article provides information regarding how to delete a file or folder during an install or uinstall.

Synopsis

This article applies to the following project types:
  • Basic MSI
  • InstallScript MSI

Windows Installer provides functionality for removing files during an installation by utilizing the RemoveFile table. Entries can be placed in this table to specify whether a file should be removed during an install, an uninstall, or both. This is useful when a product creates additional files at runtime that are not removed during the normal uninstall, the installed files to be removed during uninstall are modified by the user, or if there are files on the target system that must be removed during install.

Discussion

InstallShield 2014 and newer versions contain built-in functionality to remove files and folders. This can be accomplished in either the Setup View or the Files and folders view.

To configure file and folder removals through the Files and Folders view:

1. In the View list under Application Data, click Files and Folders.
2. In the Destination computer?s folders pane, select the destination folder that contains the file or folder that you want to be removed.
3. Right-click in the Destination computer?s files pane and click Add File Removal. The Properties dialog box opens.
4. Configure the settings as needed. For details, see File Removal Properties Dialog Box.
InstallShield adds a file or folder icon to the Destination computer?s files pane. The icon has a red X through it to indicate that it is referencing an item to be removed.

To configure file and folder removals through the Setup Design view or the Components view:

1. In the View list under Organization, click Setup Design (in installation projects) or Components.
2. In the Setup Design or Components tree, expand the node of the component that contains the file or folder that you want to be removed, and then click the Files subnode.
3. Right-click in the Files pane and click Add File Removal. The Properties dialog box opens.
4. Configure the settings as needed. For details, see File Removal Properties Dialog Box.
InstallShield adds a file or folder icon to the Files pane. The icon has a red X through it to indicate that it is referencing an item to be removed.

To edit the settings for a file or folder removal, right-click the removal item and then click Properties. The Properties dialog box opens, enabling you to edit the settings as needed.

For previous versions of InstallShield, there is no predefined support in the InstallShield Editor for specifying files and folders to be removed, however this functionality can be accomplished through the Direct Edit view of a project. The following example can be followed in order to remove the folder [INSTALLDIR]\Foldername and the file, filename.txt, contained within during an uninstall.
  1. In the Files and Folder view, create the location of the folder in order to create a Directory table entry. Right click on the newly created folder, select Properties, and note the Directory Identifier (DIRECTORY_IDENTIFIER).
  2. Browse to the Direct Edit view and select the RemoveFile table.
  3. Right click and select Add new row and enter the following:

FileKey
Component
FileName
DirProperty
InstallMode
FileKey1
Installed_Component
filename.txt
DIRECTORY_IDENTIFIER
2
FileKey2
Installed_Component
DIRECTORY_IDENTIFIER
2


Additional Information

The FileKey column need only be unique. The Component column will need to match a component in the Component table. If the FileName column is blank, the folder specified in the DirProperty will be removed if it is empty. The InstallMode can be one of three values:
1 = Remove file during install.
2 = Remove file during uninstall.
3 = Remove file during install and uninstall.
Additional information on the RemoveFile table may be found in the MSDN article RemoveFile Table.
Labels (1)
No ratings
Version history
Last update:
‎Nov 28, 2007 07:55 PM
Updated by: