ConfigDelete Example
InstallShield 2022 ยป 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 ConfigDelete function.
*
* This example script deletes statements from a configuration
* file. First, it calls ConfigFileLoad to load the file for
* editing. Next, it deletes lines that contain a FILES
* statement. Finally, it backs up the original file and
* saves the edited file.
*
* Note: Before running this script, create a configuration
* file named ISExampl.sys in the root of drive C.
* That file should include at least one FILES statement.
*
\*-----------------------------------------------------------*/
#define TARGET_CONFIG "C:\\ISExampl.sys"
#define BACKUP_CONFIG "ISExampl.bak"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_ConfigDelete(HWND);
function ExFn_ConfigDelete(hMSI)
STRING szMsg;
begin
// Load the target config file to be edited.
if (ConfigFileLoad (TARGET_CONFIG) < 0) then
MessageBox ("Unable to load " + TARGET_CONFIG + ".", SEVERE);
abort;
endif;
// Remove all lines in the file that contain the key "FILES".
if (ConfigDelete ("FILES") < 0) then
MessageBox ("ConfigDelete failed.", SEVERE);
else
// Back up the original file and save the edited file.
if ConfigFileSave (BACKUP_CONFIG) < 0 then
MessageBox ("Unable to save " + TARGET_CONFIG + ".", SEVERE);
else
MessageBox (TARGET_CONFIG + " was updated and saved.",INFORMATION);
endif;
endif;
end;