Chinaunix首页 | 论坛 | 博客
  • 博客访问: 570628
  • 博文数量: 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:35:33

 
PreviousNext
Help Library

BatchFileLoad

InstallShield 2009 » InstallScript Language Reference

The BatchFileLoad function loads a copy of the specified batch file into memory so that other advanced batch file functions can be called to operate on the file. Specify the name of the batch file you want to edit in szBatchFile or pass a null string ("") in szBatchFile to edit the default batch file, which is set initially by InstallShield to the bootup Autoexec.bat file used by the system.

Note that you can call BatchFileLoad to create a new batch file. To do so, pass in szBatchFile the name of a file that does not exist. Then call other batch functions to edit the new file. Finally, call to save the new file to disk.

Note

Note

Before using any of the advanced batch file functions, 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. To obtain the fully qualified file name of the batch file that will be used by default in the installation script, call . To specify a different batch file to be used by default in the installation script, call .

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

BatchFileLoad ( szBatchFile );

Parameters

BatchFileLoad Parameters 

Parameter

Description

szBatchFile

Specifies the fully qualified name of the batch file to load into memory. To load the current default batch file, pass a null string (""). If you specify a file in this parameter, that file becomes the default batch file. After calling this function, you can use all of the advanced batch file functions to manipulate this file.

To create a new batch file with BatchFileLoad, pass in szBatchFile the name of a file that does not exist. Then call other batch functions to edit the new file.

Return Values

BatchFileLoad Return Values 

Return Value

Description

0

BatchFileLoad successfully initialized the batch file buffer. If szConfigFile specified an existing batch file, the file was loaded into the buffer; otherwise, an empty buffer was created.

< 0

BatchFileLoad was unable to initialize the batch file buffer.

See Also


InstallShield Help Library
5 June 2008
 | 
 
 
 
 
 
 
 
 
 
 
 
 
PreviousNext
Help Library

BatchFileLoad 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 BatchFileLoad and BatchFileSave functions.

*

* This example script shows how to open a batch file for

* editing, how to create a backup of the original file, and

* how to save and close the edited file.

*

* To demonstrate how the file backup feature of BatchFileSave

* prevents the overwriting of existing files, this script loads

* and saves two different batch files.  The first batch file is

* backed up with a specific file name.  The second is backed up

* with a wildcard extension so that BatchFileSave will

* generate a unique file extension consisting of three digits.

*

* Note: Before running this script, create two batch files

*       (ISExamp1.bat and ISExamp2.bat) in the root of drive C.

*       For best effect, you should delete or move any other

*       files named ISExamp1.* or ISExamp2.*.

*

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

// Names of batch files and backup files used in this example.

#define EXAMPLE1 "ISExamp1"

#define EXAMPLE2 "ISExamp2"

// Full names of batch files.

#define EXAMPLE1_BAT "C:\\" + EXAMPLE1 + ".bat"

#define EXAMPLE2_BAT "C:\\" + EXAMPLE2 + ".bat"

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

#include "Ifx.h"

export prototype ExFn_BatchFileLoad(HWND);

function ExFn_BatchFileLoad(hMSI)

begin

    // Load EXAMPLE1_BAT.

    if (BatchFileLoad (EXAMPLE1_BAT) < 0) then

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

        abort;

    endif;

    // Use other batch file functions here to edit the first file.

    // Back up the original file with the extension "bak"; save the

    // edited file under its original name.  If ISExamp1.bak already

    // exists, BatchFileSave will generate a numbered extension.

    if (BatchFileSave (EXAMPLE1 + ".bak") < 0) then

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

        abort;

    else

        MessageBox (EXAMPLE1_BAT + " saved.",INFORMATION);

    endif;

    // Load EXAMPLE2_BAT.

    if (BatchFileLoad (EXAMPLE2_BAT) < 0) then

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

        abort;

    endif;

    // Use other batch file functions here to edit the second file.

    // Back up the original batch file with a numbered extension

    // and save the edited file under its original name.

    if (BatchFileSave (EXAMPLE2 + ".*") < 0) then

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

        abort;

    else

        MessageBox (EXAMPLE2_BAT + " saved.",INFORMATION);

    endif;

end;


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

上一篇:BatchDeleteEx

下一篇:BatchFileSave

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