BatchGetFileName Example
InstallShield 2024 » 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 BatchGetFileName and BatchSetFileName
* functions.
*
* This example script retrieves the fully qualified name of the
* default batch file, which initially is the Autoexec.bat file
* on the boot drive. It then makes C:\ISExampl.bat the default
* batch file. Finally, it retrieves the name of the default
* batch file again to show that it has been changed.
*
\*-----------------------------------------------------------*/
#define DEFAULT_BATCH_FILE "C:\\ISExampl.bat"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_BatchGetFileName(HWND);
function ExFn_BatchGetFileName(hMSI)
STRING svFilename;
begin
// Get the name of the default batch file.
if (BatchGetFileName (svFilename) < 0) then
// Report the error; then abort.
MessageBox ("First call to BatchGetFileName failed.", SEVERE);
abort;
else
// Display the name of the default batch file.
MessageBox ("The default batch file is " + svFilename + ".",
INFORMATION);
endif;
// Make C:\ISExampl.bat the default batch file.
if (BatchSetFileName(DEFAULT_BATCH_FILE) < 0) then
// Report the error.
MessageBox ("Unable to set new default batch file.", SEVERE);
else
// Verify that the default batch file has been changed.
if (BatchGetFileName(svFilename) < 0) then
// Handle an error.
MessageBox ("Second call to BatchGetFileName failed.", SEVERE);
else
// Display the name of the default batch file.
MessageBox ("Now the default batch file is " + svFilename + ".",
INFORMATION);
endif;
endif;
end;