Searching for Files on the Target System

InstallShield 2020

System Search View

The System Search view provides the functionality for locating a particular file, folder, registry or .ini file on a target system before installing your application.

Direct Editor: Basic MSI Projects

Windows Installer uses records in the Signature, AppSearch, and “locator” tables for instructions for searching for files on the target system. The Signature table contains information about the file to be located, and the AppSearch table specifies a property to set to the full path of the located file, if found.

For example, to search for a file called FindMe.exe, use the Direct Editor to add the following record to the Signature table.

Sample Data for the Signature Table

Table Column

Sample Data

Signature

findme_sig

FileName

FindMe.exe

Note that other fields in the Signature table enable you to specify optional version, size, date, and language information.

Add the following record to the AppSearch table.

Sample Data for the AppSearch Table

Table Column

Sample Data

 

Property

LOCATION_OF_FINDME

Must be a public property.

Signature_

findme_sig

Same name used in Signature table.

There are four locator tables in which you can specify where Windows Installer should begin searching for the file: CompLocator, RegLocator, IniLocator, and DrLocator. To search for a file in a specific directory, use the DrLocator table. For example, to search for FindMe.exe in the user’s Program Files directory, we add the following record to the DrLocator table.

Sample Data for the DrLocator Table

Table Column

Sample Data

Signature

findme_sig

Parent

 

Path

[ProgramFilesFolder]

Depth

2

After the AppSearch action runs, the public property LOCATION_OF_FINDME will contain the full path to FindMe.exe on the end user’s system if it exists; if the file is not located, this property will be undefined.

InstallScript: InstallScript MSI Projects

The FindFile and FindAllFiles functions enable you to search for existing files on the target system. For example, an implementation of the OnAppSearch event-handler function that searches for a file called FindMe.exe in the user’s Program Files folder might appear as follows:

function OnAppSearch( )

    STRING svFoundFile;

begin

    FindAllFiles(PROGRAMFILES, "FindMe.exe", svFoundFile, RESET);

    MessageBox("Found FindMe.exe at: " + svFoundFile, INFORMATION);

end;

See Also