Create Lnk Shortcut using VBScript

Dim objShell : Set objShell = CreateObject("WScript.Shell")
Dim userProfileFolder : userProfileFolder = objShell.ExpandEnvironmentStrings("%USERPROFILE%")
Dim desktopFolder : desktopFolder = userProfileFolder & "\Desktop"
Dim programFilesFolder : programFilesFolder = objShell.ExpandEnvironmentStrings("%ProgramFiles%")
Dim shortcutName : shortcutName = "Alkane Test"
Dim shortcutDescription : shortcutDescription = "Alkane Solutions Description"
Dim shortcutArguments : shortcutArguments = ""
Dim workingDir : workingDir = programFilesFolder & "\AlkaneSolutions\"
Dim shortcutTarget : shortcutTarget = workingDir & "test.exe"
Dim shortcutIcon : shortcutIcon = workingDir & "test.exe, 2"
'Create the shortcut
Dim lnk : Set lnk = objShell.CreateShortcut(desktopFolder & "\" & shortcutName & ".lnk")
lnk.TargetPath = shortcutTarget
lnk.Arguments = shortcutArguments
lnk.Description = shortcutDescription
lnk.HotKey = "ALT+CTRL+F"
lnk.IconLocation = shortcutIcon
lnk.WindowStyle = "1"
lnk.WorkingDirectory = workingDir
lnk.Save
'Clean up 
Set lnk = Nothing
Set objShell = Nothing

 

Adding a Network Shortcut when the Network Location is Unavailable

Many packagers wonder how they can create a shortcut to a network location when they dont have access to it during the packaging process. Here’s how:

Step 1

Set up a property called WkDir (if you call it something else, ensure it is NOT all in uppercase. It should be mixed case) in the Property table and set the value to the location of the network file you want in your shortcut. For example: \\XYZ\shared\application\

Property Working Directory

Step 2

In the WkDir column of the Shortcut table for your shortcut, enter WkDir (no square brackets no quotes).

Shortcut Network Location

Step 3

Create another property in the Property table called NetworkFilePath, with a value of the full path to your network file. For example: \\XYZ\shared\application\test.exe

Property Target

Step 4

In the Shortcut table for your shortcut, enter the [NetworkFilePath] (with the square brackets) in the Target column.

Shortcut Network Location