分类:
2009-03-27 18:39:00
InstallShield 2009 » InstallScript Language Reference
The BatchFileSave function saves to disk a batch file that has been loaded into memory with the function . The file is saved under its original name. If a file name is specified in szBackupFile, the original file is renamed with that file name before the edited file is written to disk. If szBackupFile contains a null string (""), the original file is replaced with the modified file. If you do not call BatchFileSave when you are finished modifying a batch file with advanced batch file functions, all modifications will be lost.
Note
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.
BatchFileSave ( szBackupFile );
Parameter |
Description |
---|---|
szBackupFile |
Specifies whether a backup copy of the original file as it existed before editing should be saved.
Once the backup has been created, InstallShield stores the backup file name in the system variable . If the batch file specified by the last call to BatchFileLoad did not exist, then the backup file is identical to the batch file created by the call to BatchFileSave. If szBackupFile specifies the name of the original batch file, then a backup file is not created. |
Return Value |
Description |
---|---|
0 |
BatchFileSave successfully saved the batch file in memory to disk. |
< 0 |
BatchFileSave was unable to save the batch file to disk. |
See Also
InstallShield Help Library 5 June 2008 | | |
Popup | ||||
InstallShield 2009 » InstallScript Language Reference
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_BatchFileSave(HWND);
function ExFn_BatchFileSave(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 | | |
Popup | ||||