Chinaunix首页 | 论坛 | 博客
  • 博客访问: 570260
  • 博文数量: 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:34:55

 
PreviousNext
Help Library

BatchDeleteEx

InstallShield 2009 » InstallScript Language Reference

The BatchDeleteEx function deletes lines in a batch file that contain the value specified in szKey.

Note

Note

Before calling BatchDeleteEx, 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

BatchDeleteEx ( szKey, nOptions );

Parameters

BatchDeleteEx Parameters 

Parameter

Description

szKey

Specifies the reference keyword that identifies the line or lines to be deleted.

nOptions

Indicates whether szKey specifies an environment variable in a SET statement or a command. Pass one of the following predefined constants in this parameter:

  • 0—Specifies that szKey is an environment variable in a SET statement. An environment variable is either a predefined identifier (such as PATH, COMSPEC, and LIB), or a user-defined identifier. For example, the following statement would be deleted if the value of szKey was "LIBPATH" and nOptions was set to 0:

SET LIBPATH=C:\Lang\Lib

  • COMMAND—Specifies that szKey is either a DOS command or a program file name.

Return Values

BatchDeleteEx Return Values 

Return Value

Description

0

BatchDeleteEx successfully deleted lines containing the specified value.

< 0

BatchFileLoad was unable to delete lines containing the specified value.

See Also


InstallShield Help Library
5 June 2008
 | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
PreviousNext
Help Library

BatchDeleteEx 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 BatchDeleteEx function.

*

* This example script deletes lines from a batch file.  First,

* it calls BatchFileLoad to load the file.  Next, it deletes

* all lines with a PATH command.  Then it deletes all lines

* that reference MyApp.exe (for example, C:\MyApps\MyApp.exe).

* Finally, it backs up the original file and saves the

* edited file under its original name.

*

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

*       named ISExampl.bat in the root of drive C.  For

*       best effect, that file should include the

*       following lines:

*

*       SET PATH=C:\Windows

*       C:\MyApps\MyApp.exe

*

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

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

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

#include "Ifx.h"

export prototype ExFn_BatchDeleteEx(HWND);

function ExFn_BatchDeleteEx(hMSI)

    STRING szBackupFile;

begin

    // Load or create the batch file to be edited.

    if (BatchFileLoad (EXAMPLE_BAT) < 0) then

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

        abort;

    endif;

    // Delete all SET PATH= commands.

    BatchDeleteEx ("PATH", 0);

    

    // Delete all lines with references to MyApp.exe.

    BatchDeleteEx ("MyApp.exe", COMMAND);

    // Save the edited batch file.

    if (BatchFileSave("Example.bak") < 0) then

        MessageBox ("Unable to save " + EXAMPLE_BAT + ".", SEVERE);

    else

        MessageBox ("Batch file saved.",INFORMATION);

    endif;

    

end;


InstallShield Help Library
5 June 2008
 | 
阅读(659) | 评论(0) | 转发(0) |
0

上一篇:BatchAdd

下一篇:BatchFileLoad

给主人留下些什么吧!~~