InstallShield 2016 » 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 CreateShortcut function.
*
* This example places a subfolder on the desktop and a shortcut
* pointing to an executable file in the new folder. The folder is
* a shortcut that points to an actual directory. From this
* folder, the end user can launch a shortcut that runs the program.
*
* Note: Before running this script, set the preprocessor
* constants so that they reference the fully qualified
* names of the Windows Notepad executable file and a valid
* text file on the target system.
*
\*-----------------------------------------------------------*/
#define FOLDER "C:\\Windows\\"
#define PROGRAM "C:\\Windows\\Notepad.exe"
#define PARAM "C:\\Windows\\Readme.txt"
function OnFirstUIAfter()
STRING szShortcutFolder, szName, szCommandLine, szWorkingDir;
STRING szIconPath, szShortCutKey;
STRING szProgram, szParam, szFolderDir;
NUMBER nIcon, nFlag, nResult;
begin
// szShortcutFolder is the Desktop on the local system.
szShortcutFolder = FOLDER_DESKTOP;
szName = "Example folder 3";
// Create the folder to which the folder icon will point.
szFolderDir = FOLDER ^ szName;
CreateDir(szFolderDir);
// The command line for the folder icon must be the folder path, and
// it must be enclosed in quotation marks if the path is longer than
// eight characters.
szCommandLine = szFolderDir;
LongPathToQuote(szCommandLine, TRUE);
szWorkingDir = "";
szIconPath = "";
nIcon = 0;
szShortCutKey = "";
nFlag = CS_OPTION_FLAG_REPLACE_EXISTING|CS_OPTION_FLAG_RUN_MINIMIZED;
// Create the folder shortcut, and show the folder it points to.
nResult = CreateShortcut (szShortcutFolder, szName, szCommandLine,
szWorkingDir, szIconPath, nIcon, szShortCutKey,
nFlag);
if (nResult < 0) then
MessageBox ("CreateShortcut failed.", SEVERE);
else
SprintfBox (INFORMATION, "CreateShortcut", "%s created successfully.",
szName);
endif;
// Display the folder just created.
ShowProgramFolder (szFolderDir, SW_SHOW);
// Add the example shortcut to the newly created folder.
szShortcutFolder = szFolderDir;
szName = "Notepad Example 3";
// Make sure the white space is not seen as a delimiter.
szProgram = PROGRAM;
LongPathToQuote (szProgram, TRUE);
szParam = PARAM;
LongPathToShortPath (szParam);
szCommandLine = szProgram + " " + szParam;
szWorkingDir = "";
szIconPath = "";
nResult = CreateShortcut (szShortcutFolder, szName, szCommandLine,
szWorkingDir, szIconPath, nIcon, szShortCutKey,
nFlag);
if (nResult < 0) then
MessageBox ("CreateShortcut failed.", SEVERE);
else
SprintfBox (INFORMATION, "CreateShortcut", "%s created successfully.",
szName);
endif;
end;
InstallShield 2016 Help LibraryMay 2017 |
Copyright Information | Flexera Software |