1

This is weird that in InstallScript projects in InstallShield there is no dialog with a checkbox that allows the user to choose whether or not shortcuts on Desktop, Start Menu, or everywhere else are created at the end of the installation, and I never want to create installers that force creation of shortcuts on Desktop on users who don't want it.

1 Answers1

0

I did this too. First, I modified the SetupType dialog to have 2 checkboxes asking about the shortcuts. If true, they should create the appropriate shortcut. I linked these to custom properties (SET_START_MENU_SHORTCUT and SET_DESKTOP_SHORTCUT), and then check those properties later in my script which I've attached below. Then I let the installer create both shortcuts and delete whichever ones need to be deleted. This is the solution Revenera told me to use.

function SelectiveRemoveShortcuts(hMSI)
#define shortcutName "Launch Foo.exe"
STRING szCompany;
STRING szStartMenuPath;
STRING startMenuShortcut;
STRING szDesktop;
STRING szDesktopShortcut;
STRING nvSMProp;
string nvDesktopProp;
NUMBER nvSize;
begin
    nvSize = 1;
    szCompany = FOLDER_COMMON_APPDATA + "\\Start Menu\\Programs\\CompanyName\\";
    szStartMenuPath = szCompany + "Foo\\";
    startMenuShortcut = szStartMenuPath + shortcutName;
    szDesktop = FOLDER_DESKTOP;
    szDesktopShortcut = szDesktop + "\\"+shortcutName;
    MsiGetProperty(hMSI, "SET_START_MENU_SHORTCUT", nvSMProp, nvSize);
    MsiGetProperty(hMSI, "SET_DESKTOP_SHORTCUT", nvDesktopProp, nvSize); 
    if nvSMProp != "1" then
        DeleteShortcut(szStartMenuPath, shortcutName);
        DeleteDir(szStartMenuPath, ONLYDIR);
        DeleteDir(szCompany, ONLYDIR);
    endif;
    if nvDesktopProp != "1" then
        DeleteShortcut(szDesktop, shortcutName);
    endif;

end;
Isaac
  • 334
  • 1
  • 4
  • 12