When building an installer for a Java desktop application, I needed to leave a script installed that could re-create a lost desktop shortcut by just clicking the script. I came across a VBScript (mkshortcut.vbs) that does what I wanted:
Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set link = Shell.CreateShortcut(DesktopPath & "\MyApp.lnk")
link.Arguments = "Arg1 Arg2 Arg3"
link.Description = "A Tooltip"
link.HotKey = "CTRL+ALT+SHIFT+F"
link.IconLocation = "$INSTALL_PATH\images\MyApp.ico"
link.TargetPath = "$INSTALL_PATH\MyApp.jar"
link.WindowStyle = 1
link.WorkingDirectory = "$INSTALL_PATH"
link.Save
Let's assume this script is dropped into the bin/ directory of your $INSTALL_PATH when the IzPack installer does it's work. The trick is just to have IzPack replace $INSTALL_PATH in the script with the user-chosen install path and then have it automatically execute the script. This is accomplished with the following XML in your main application pack stanza.
<pack name="MyApp - Core" required="yes">
<description></description>
<fileset dir="dist" targetdir="$INSTALL_PATH">
<include name="bin/mkshortcut.vbs"/>
<include name="MyApp.jar"/>
<include name="bin/MyApp.ico"/>
</fileset>
<parsable targetfile="$INSTALL_PATH/bin/mkshortcut.vbs"/>
<executable os="windows" keep="true" failure="warn" stage="postinstall"
targetfile="wscript.exe">
<args>
<arg value="$INSTALL_PATH/bin/mkshortcut.vbs"/>
</args>
</executable>
</pack>



















