Adding shortcuts to the desktop with a Deployment Tool Package

Date: 2 July 2011
Product/Release: Visual LANSA Deployment Tool V12
Abstract: How to use After-Install Commands to add your own shortcuts to the Desktop
Submitted By: LANSA Technical Support


V12 includes an enhancement to create additional shortcuts with your deployment tool package. This enhancement only allows you to create shortcuts in the specified Start Menu folder. In order to create shortcuts on the Desktop, you can use the Windows Scripting Engine to dynamically create the shortcuts.


  1. The first step is to create the Windows Script that will create the shortcut. You can use the following example:
    '* ***************************************
    '* Create/Update a shortcut on the Desktop
    '* Usage
    '* cscript.exe <this file>.vbs "/LinkName:<my link name>" "/AppDesc:<App Description>" "/StartFile:<start file name>" "/ANSARoot:<root dir>" "/Partition:<ppp>"
    '* e.g.
    '* As an after install command:
    '* ALL    SYSTEM    cscript.exe "%dirp%execute\shortcut.vbs" "/LinkName:My Shortcut" "/AppDesc:Does what i want" "/StartFile:x_start.001" "/LANSARoot:%DIRL%" "/Partition:%PART%"
    '* ***************************************
    '* Ignore Errors
    on error resume next
    '* Definitions
    Const ALL_USERS_DESKTOP = &H19&
    Dim DesktopPath
    Set objShell = CreateObject("Shell.Application")
    '* Determine Desktop path
    Set objFolder = objShell.Namespace(ALL_USERS_DESKTOP)
    Set objFolderItem = objFolder.Self
    DesktopPath = objFolderItem.Path
    '* Next line for debugging purposes
    '*Wscript.Echo DesktopPath
    '* Get arguments passed from command line
    If WScript.Arguments.Named.Exists("LinkName") Then
    strShortcutName = WScript.Arguments.Named("LinkName")
    strShortcutName = "Start Application"
    End If
    If WScript.Arguments.Named.Exists("AppDesc") Then
    strAppDesc = WScript.Arguments.Named("AppDesc")
    strAppDesc = "LANSA Application"
    End If
    If WScript.Arguments.Named.Exists("StartFile") Then
    strStartFile = WScript.Arguments.Named("StartFile")
    strStartFile = "x_start.001"
    End If
    If WScript.Arguments.Named.Exists("LANSARoot") Then
    strLANSARoot = WScript.Arguments.Named("LANSARoot")
    strLANSARoot = "C:\X_WIN95"
    End If
    If WScript.Arguments.Named.Exists("Partition") Then 
    strPartition = WScript.Arguments.Named("Partition")
    strPartition = "dem"
    End If
    '* Create and update shortcuts
    set WshShell = WScript.CreateObject("WScript.Shell")
    '* Create shortcut on the desktop (adjust the path and names to match your stuff here)
    set oShortCutLink = WshShell.CreateShortcut(DesktopPath & "\" & strShortcutName & ".lnk")
    oShortCutLink.TargetPath = (strLANSARoot & "\X_LANSA\EXECUTE\x_start.exe")
    oShortCutLink.Arguments = "=" & strStartFile
    oShortCutLink.WorkingDirectory = strLANSARoot & "\X_LANSA\x_" & strPartition & "\SOURCE"
    oShortCutLink.Description = strAppDesc
    oShortCutLink.IconLocation = oShortCutLink.TargetPath & ", 0"
  2. Save it as a text file with the extension "vbs" (i.e. myshortcut.vbs). Note that if creating from notepad you will need to change the filetype to *.* (All Files) before saving, otherwise it will automatically add ".txt" to the end of the filename.
  3. Add this file to your package as a Non-LANSA file (on the Other Objects tab). Refer to the LANSA Application Deployment Tool guide for instructions. You can accept the default DFTPATH path as it will put the file in the partition Execute folder.
  4. Now open the 'Commands to execute before and after import' dialog and select Commands to execute after install. Add the following command:

     ALL     SYSTEM     cscript.exe "%dirp%execute\shortcut.vbs" "/LinkName:My Shortcut" "/AppDesc:Does what i want" "/StartFile:x_start.001" "/LANSARoot:%DIRL%" "/Partition:%PART%"

    Change the text after the /LinkName: to select a name for your shortcut (note there is no space after the colon), and change the text after /AppDesc: to enter a description for the shortcut (this will become the tooltip if you hover over it with your mouse). This script was specifically written to create a shortcut that will start a LANSA program, hence StartFile should point to a start file that will exist in your partition source directory. LANSARoot and Partition should stay as they are.

This script is provided as-is and should cater for most requirements. However it can be edited if you have any specific shortcuts you want to create. This script was inspired by the guys at Retailer Owned Research Company (RORC)