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.
Asked
Active
Viewed 102 times
1 Answers
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
-
Does it matter if it's pure InstallScript or InstallScript MSI? – אור הושמנד Mar 09 '22 at 20:40
-
@אורהושמנד I'm using a basic MSI project. I imagine you could do the same in any project, though. – Isaac Mar 10 '22 at 14:08