Shortcuts as features

  • Imprimir
Este artigo ainda não foi traduzido.

In this example for Setup Factory, I show how you can offer the creation of shortcuts to the application being installed in the feature tree.

It is important that you clear all checkmarks for the application in the Location setting of Setup Factory:

The end user will define which shortcuts should be created with the aid of the "Select Packages" screen:

How to use

  • You have to create a Package for each shortcut you wish to offer. Go to Project > Packages > Add and create Packages as you wish, setting an ID, display name and description that will be shown on the "Select Packages" screen.
  • Once you have created Packages for all shortcuts, include them in the "Select Packages" screen. If the screen is not present in your project yet, add it first. Then add a Category, name it "Shortcuts", and place the packages of the shortcuts in it.
  • Finally, you must check which Packages were selected for installation, and perform the creation of the correspondent shortcut. This is best done in the On Post Install script, with a Lua code similar to this:
 
if (SetupData.GetPackageProperties("desktop_icon").Install) then
    local iconfolder = Shell.GetFolder(SHF_DESKTOP);
    -- create shortcut
    Shell.CreateShortcut(iconfolder, SessionVar.Expand("%ProductName%"),
        SessionVar.Expand("%AppFolder%\\Sample.exe"), "", "", "", 0, SW_SHOWNORMAL, nil, "");
    -- add to uninstaller
    UninstallData.AddItem(UNINDATA_SHORTCUTS, { Filename=iconfolder ..
        "\\" .. SessionVar.Expand("%ProductName%.lnk") });
end
 
if (SetupData.GetPackageProperties("quicklaunch_icon").Install) then
    local iconfolder = SessionVar.Expand("%ApplicationDataFolder%") ..
        "\\Microsoft\\Internet Explorer\\Quick Launch";
    -- create shortcut
    Shell.CreateShortcut(iconfolder, SessionVar.Expand("%ProductName%"),
        SessionVar.Expand("%AppFolder%\\Sample.exe"), "", "", "", 0, SW_SHOWNORMAL, nil, "");
    -- add to uninstaller
    UninstallData.AddItem(UNINDATA_SHORTCUTS, { Filename=iconfolder ..
        "\\" .. SessionVar.Expand("%ProductName%.lnk") });
end
 
if (SetupData.GetPackageProperties("startmenu_icon").Install) then 
    local iconfolder = Shell.GetFolder(SHF_STARTMENU);
    -- create shortcut
    Shell.CreateShortcut(iconfolder, SessionVar.Expand("%ProductName%"),
        SessionVar.Expand("%AppFolder%\\Sample.exe"), "", "", "", 0, SW_SHOWNORMAL, nil, "");
    -- add to uninstaller
    UninstallData.AddItem(UNINDATA_SHORTCUTS, { Filename=iconfolder ..
        "\\" .. SessionVar.Expand("%ProductName%.lnk") });
end
 

Download

Sample project

Click to downloadFile size: 20 KB
Updated: January 2013

Windows 7 or later:
The Quick Launch bar is no longer shown by default on the taskbar after a fresh install of Windows 7. In order to get the bar back, so Quick Launch icons show up correctly, it may be required to recreate the bar first. You can find instructions on several sites, like How-To Geek.

Remember that all shortcuts created manually with scripting must also be removed manually with scripting: Include proper removal commands using UninstallData.AddItem() or create File.Delete() or Folder.Delete() actions in the On Pre Uninstall script of the Uninstaller.

You can find more ways for handling shortcuts in the Custom Shortcuts screen.

Don't have Setup Factory?

If you want to purchase a license for Setup Factory 9, now is a good time! You can get 10% off the list price simply by clicking the banner below:

 

Our Plugins & Examples Feed

  • POP3 Actions plugin released

    A new, free actions plugin was released today. With it, the developer can check POP3...

  • Reminder: Update Serial Number Validation and/or Subscription Validation

    Next week IPInfoDB's API 2.0 will stop working. If you use an older version than...

Subscribe now!

Advertisement