by 7Z Software (2 Submissions)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 1st October 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Easiest method to create shortcut - no API's required!
API Declarations
Dim objShellLink As Object
Set objWshShell = CreateObject("WScript.Shell")
' so don't use Option Explicit
' or just declare variables
'
strDesktop = objWshShell.SpecialFolders("Desktop")
Set objShellLink = objWshShell.CreateShortcut(strDesktop & "\Notepad.lnk")objShellLink.TargetPath = "C:\WINNT\NOTEPAD.EXE" ' or "http://www.microsoft.com"
objShellLink.WindowStyle = 1
objShellLink.Hotkey = "CTRL+SHIFT+F"
objShellLink.IconLocation = "NOTEPAD.EXE, 0"
objShellLink.Description = "This is my shortcut!"
objShellLink.WorkingDirectory = strDesktop
objShellLink.Save
Set objShellLink = Nothing
Set objWshShell = Nothing