Chinaunix首页 | 论坛 | 博客
  • 博客访问: 588246
  • 博文数量: 208
  • 博客积分: 3286
  • 博客等级: 中校
  • 技术积分: 1780
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-24 20:38
文章分类

全部博文(208)

文章存档

2012年(7)

2011年(28)

2010年(21)

2009年(76)

2008年(65)

2007年(11)

我的朋友

分类:

2009-03-27 18:43:11

 
PreviousNext
Help Library

BatchFind

InstallShield 2009 » 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

Note

Before calling BatchFind, you must call to load the file to be modified into memory. After you modify the file, call 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


InstallShield Help Library
5 June 2008
 | 
 
 
 
 
 
 
 
 
 
 
PreviousNext
Help Library

BatchFind Example

InstallShield 2009 » InstallScript Language Reference

Note

Note

To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.

/*-----------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the BatchFind function.

*

* This example script searches a batch file and reports whether

* or not the file includes a command that references SHARE.EXE.

* It then finds and displays all PATH and SET PATH statements.

*

* Note: Before running this script, create a batch file

*       named ISExampl.bat and store it in the root of

*       drive C. The batch file should include a command

*       to launch Share.exe, and it should contain at least

*       one PATH or SET PATH= statement.

*

\*-----------------------------------------------------------*/

#define TARGET_BATCH "C:\\ISExampl.bat"

// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"

export prototype ExFn_BatchFind(HWND);

function ExFn_BatchFind(hMSI)

    STRING svResult;

    NUMBER nResult;

begin

    // Load the target batch file.

    if (BatchFileLoad (TARGET_BATCH ) < 0) then

        MessageBox ("Unable to load " + TARGET_BATCH  + ".", SEVERE);

        abort;

    endif;

    // Check for a SHARE.EXE command.

    nResult = BatchFind ("SHARE.EXE", svResult, COMMAND);

    if (nResult < 0) then

        MessageBox ("SHARE.EXE command not found.", WARNING);

    else

        MessageBox ("SHARE.EXE command found.", INFORMATION);

    endif;

    // Find the first PATH or SET PATH= statement.  Pass RESTART in

    // the third parameter to begin searching at the top of the file.

    nResult = BatchFind ("PATH", svResult, RESTART);

    if (nResult < 0) then

        MessageBox ("PATH command not found.", WARNING);

    else

        // Loop while PATH commands are found.

        while (nResult = 0)

            MessageBox (svResult, INFORMATION);

            // Find the next PATH command.  Pass CONTINUE in the

            // third parameter to continue the search with the

            // statement that follows the last match.

            nResult = BatchFind ("PATH", svResult, CONTINUE);

        endwhile;

        MessageBox ("No more PATH commands.", WARNING);

    endif;

end;


InstallShield Help Library
5 June 2008
 | 
阅读(727) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~