BatchFind

InstallShield 2024 » InstallScript Language Reference

The BatchFind function searches a batch file for one or more occurrences of the reference key specified in szRefKey. If you specify the constant RESTART in nOptions, the first occurrence of the reference key is returned. To find the next occurrence of szRefKey, call this function repeatedly with nOptions set to CONTINUE.

Note:Before calling BatchFind, you must call BatchFileLoad to load the file to be modified into memory. After you modify the file, call BatchFileSave to save it to disk.

Do not mix the Ez batch file functions with the advanced batch file functions. After calling BatchFileLoad, you cannot use Ez batch file functions until you have called BatchFileSave to save the file.

Syntax

BatchFind ( szRefKey, svResult, nOptions );

Parameters

BatchFind Parameters

Parameter

Description

szRefKey

Specifies the reference key to search for. The reference key can be an environment variable, a DOS command, or a program name. If the reference key is a file name and you do not specify a file extension, the function returns all reference keys with the base file name. For example, if you specify Win.com, the search looks for this reference key only. If you specify Win, the reference keys Win.exe, Win.dll, Win.sys, and so on will be returned if they exist in the batch file.

svResult

Specifies the value of the reference key that was found in the batch file.

nOptions

Specifies where to start the search; pass one of the following predefined constants in this parameter:

CONTINUE—Starts the search from the current position in the batch file.
RESTART—Starts the search from the beginning of the batch file.

When the reference key you are searching for is a DOS command or program name (not an environment variable), use the OR operator to combine the constant COMMAND with CONTINUE or RESTART, as shown below:

BatchFind ("SCAN.EXE", svResult, COMMAND | RESTART);

Return Values

BatchFind Return Values

Return Value

Description

0

BatchFind successfully found the value of szRefKey and returned it in svResult.

< 0

BatchFind was unable to find the value of szRefKey and return it in svResult.

See Also