Home » General Scripting and Coding » VBScript » Create Lnk Shortcut using VBScript

Create Lnk Shortcut using VBScript

Posted on by
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

 

Comments have now been disabled. If you have a question to ask about this post please ask the community!