This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- Create a shortcut using installscript based on user input and delete the shortcut on uninstalling th...
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
Create a shortcut using installscript based on user input and delete the shortcut on uninstalling the installer
Create a shortcut using installscript based on user input and delete the shortcut on uninstalling the installer
Introduction
This article will discuss how to create a shortcut based on user input using a property value and Create a shortcut using installscript and delete the shortcut on uninstall
Instructions
This article explains how to create a shortcut based on user request. This information applies to the following InstallShield project types:
- Basic MSI
- Installscript MSI
Steps to create a Project:
- Create Basic MSI Project
- Add a Feature and add component and files inside component
- Add exe files to component for which we want to create a shortcut.
- Go to installscript view and Right and add Setup.rul
- Copy paste the code at the bottom of this article into setup.rul (Replace shortcut name as per your exe added in components Example: Notepad.exe)
- Make sure CreateShortCut and DeleteShortCut functions are added
- Go to CustomAction view and add 2 Installscript Custom Actions and rename it.(CreateShortcut,DeleteShortcut)
- For Create Shortcut CA select the function CreateShortcut and for Delete Shortcut CA select the function name as DeleteShortcut from drop down
- Set the Condition for both Customaction (for EX: Create shortcut add condition NOT installed, and for Delete Shortcut add REMOVE~="ALL")
- And select Install Exec sequence as required.
- Go to Dialogs and Add a new Interior Dialog dialog
- Go to property manager and add 2 property DESKTOP_SHORTCUT and START_MENU_SHORTCUT
- Make sure the value column is empty, so that the checkbox is unchecked by default
- Rename the new dialog (Example: ShortcutDialog)
- And add 2 checkbox like shown below
- And set above created 2 property to this 2 checkbox filed
- Now Sequence the new dialog (ShortcutDialog) BACK and NEXT button as needed under behavior.
- EX: BACK --> Customer information , NEXT button to Setup Type
- Similarly in Customer information Dialog the NEXT Button should be change to ShortcutDialog
- Save and build the project
- Install the setup.exe and click NEXT and go to Shortcut checkbox dialog
- Click NEXT and Complete Installation
- Check shortcut created under desktop and under Appdata folder (EX: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\CompanyName)
#include "ifx.h"
export prototype CreateShortCut(HWND);
export prototype DeleteShortCut(HWND);
function CreateShortCut(hMSI)
STRING szShortcutFolder, szName, szCommandLine, szWorkingDir ;
STRING szIconPath, szShortCutKey,szValue,szValue1;
STRING szProgram, szParam, szFolderDir,szCmd;
NUMBER nIcon, nFlag, nResult, nvBufferSize;
begin
//Get Supportdir for icon
szIconPath = WINDIR ^ "regedit.exe";
//szIconPath = sMySUPPORTDIR +"\\" + "icon32.ico";
szShortcutFolder = FOLDER_DESKTOP;
szName = "DesktopShortcut";
szCommandLine = INSTALLDIR ^ "Notepad2.exe";
LongPathToQuote (szCommandLine, TRUE);
szWorkingDir = "";
nIcon = 1;
szShortCutKey = "";
nFlag = CS_OPTION_FLAG_REPLACE_EXISTING|CS_OPTION_FLAG_RUN_MINIMIZED;
MsiGetProperty(hMSI,"DESKTOP_SHORTCUT",szValue,nIcon);
if ( szValue == "1") then
Delay (2);
// Create the folder shortcut, and show the folder it points to.
if ( CreateShortcut(szShortcutFolder, szName, szCommandLine,szWorkingDir, szIconPath, nIcon, szShortCutKey,nFlag) < 0) then
Delay (1);
MessageBox ("DESKTOP Shortcut Not Created.", SEVERE);
endif;
endif;
//Creating StartMenu Shortcut
szIconPath = INSTALLDIR ^ "Explorer.exe";
szShortcutFolder = FOLDER_STARTMENU ^ "Programs\\CompanyName";
szName = "StartmenuShortcut";
szCommandLine = INSTALLDIR ^ "Uno.exe";
LongPathToQuote (szCommandLine, TRUE);
szWorkingDir = "";
nIcon = 1;
szShortCutKey = "";
nFlag = CS_OPTION_FLAG_REPLACE_EXISTING|CS_OPTION_FLAG_RUN_MINIMIZED;
MsiGetProperty(hMSI,"START_MENU_SHORTCUT",szValue1,nIcon);
if ( szValue1 == "1") then
Delay (2);
// Create the folder shortcut, and show the folder it points to.
if ( CreateShortcut(szShortcutFolder, szName, szCommandLine,szWorkingDir, szIconPath, nIcon, szShortCutKey,nFlag) < 0) then
Delay (1);
MessageBox ("STARTMENU Shortcut Not Created.", SEVERE);
endif;
endif;
end;
//Script to delete shortcut on uninstallation.
function DeleteShortCut(hMSI)
#define shortcutName "DesktopShortcut"
#define shortcutName1 "StartmenuShortcut"
STRING szCompany,szStartMenuPath,startMenuShortcut,szDesktop,szDesktopShortcut;
STRING nvSMProp,nvDesktopProp;
NUMBER nBuffer;
begin
nBuffer = MAX_PATH + 1;
szDesktop = FOLDER_DESKTOP;
szDesktopShortcut = INSTALLDIR ^ "Notepad2.exe";
if (Is(FILE_EXISTS, szDesktopShortcut) = FALSE) then
Delay (1);
DeleteShortcut(szDesktop, shortcutName);
else
MessageBox("No shortcut to delete", INFORMATION);
endif;
szCompany = FOLDER_COMMON_APPDATA + "Microsoft\\Windows\\Start Menu\\Programs\\CompanyName\\";
if (Is(FILE_EXISTS, szDesktopShortcut) = FALSE) then
Delay (1);
DeleteShortcut(szCompany, shortcutName1);
else
MessageBox("No shortcut to delete", INFORMATION);
endif;
end;
More Information
Click here for installscript help documentation on create shortcut
Click here for installscript help documentation on delete shortcut
No ratings