The CreateShortcut method creates and returns a WshShortcut object.
The
CreateShortcut method creates either a WshShortcut or
WshURLShortcut object depending on the specified
strPathName. If strPathName has the extension ".lnk",
then a WshShortcut object is created and returned. If
strPathName has the extension ".url", then a
WshURLShortcut object is created and returned.
If strPathName points to a file that already exists, then the
shortcut file is opened and can be modified via the shortcut object
returned by CreateShortcut. Otherwise, the shortcut file will
not be created until the Save method of the shortcut object is
called.
Set WshShell =
CreateObject("WScript.Shell")
strDesktopPath =
WshShell.SpecialFolders("Desktop")
Set objShortcutLnk
= WshShell.CreateShortcut(strDesktopPath &
"\notepad.lnk")
objShortcutLnk.TargetPath = "notepad"
objShortcutLnk.Save
Set objShortcutUrl =
WshShell.CreateShortcut(strDesktopPath &
"\devguru.url")
objShortcutUrl.TargetPath =
"http://www.devguru.com"
objShortcutUrl.SaveThis VBScript code creates one program shortcut to Notepad and one URL shortcut to the DevGuru web site, then saves both shortcuts on the user's desktop.