9.10. Shortcuts
The Shell object
provides the ability to create shortcuts via the
CreateShortCut method. This method returns a
WshShortCut object:
objShortCut = objShell.CreateShortcut(strPath)Once you have created a
Shortcut object, you can set properties for it.
This object provides the same settings that are available when
creating shortcuts using Explorer.Table 9-10 lists the properties that can be set for
the shortcut.
Save method to save and update the shortcut.
'create a shortcut on desktop linked to hello script
Set objShell = CreateObject("Wscript.Shell")
strDesktop = objShell.SpecialFolders("Desktop") 'get path to desktop
Set objShortcut = objShell.CreateShortcut(strDesktop & "\nlink.lnk")
objShortcut.TargetPath = "D:\heh.vbs" 'script to execute
objShortcut.Save 'save and update shortcut