分类:
2009-03-27 18:34:55
InstallShield 2009 » InstallScript Language Reference
The BatchDeleteEx function deletes lines in a batch file that contain the value specified in szKey.
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.
BatchDeleteEx ( szKey, nOptions );
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:
SET LIBPATH=C:\Lang\Lib
|
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 | | |
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 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 | | |
Popup | ||||