BatchDeleteEx Example
InstallShield 2026 » 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;