DeleteShortcut Example

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 DeleteShortcut and DeleteShortcutFolder

* functions.

*

* This script deletes the Notepad Example 3 shortcut from the

* Example folder 3 folder. DeleteShortcutFolder is then

* called again to delete this folder.

*

* Note: In order for this script to run properly, you must set

*       the preprocessor constants to a valid folder and shortcut

*       on the target system. To easily create this example

*       folder and shortcut, run the CreateShortcut example 3.

*

\*--------------------------------------------------------------*/

 

#define FOLDER "C:\\Windows\\Example folder 3"

#define SHORTCUT "Notepad Example 3"

 

function OnFirstUIAfter()

begin

 

    // Display the folder.

    ShowProgramFolder (FOLDER, SW_SHOW);

    Delay (3);

 

    // Delete the Notepad Example 3 shortcut.

    if (DeleteShortcut (FOLDER, SHORTCUT) < 0) then

        MessageBox ("DeleteShortcut failed.", SEVERE);

    endif;

 

    // Delete the Example folder 3 shortcut.

    if (DeleteShortcutFolder (FOLDER) < 0) then

        MessageBox ("DeleteShortcutFolder failed.", SEVERE);

    endif;

 

end;