Section 9.10. Shortcuts

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.

Table 9-10. Shortcut object properties

Parameter

Type

Description

Description

String

Shortcut description.

Hotkey

String

Hotkey used to execute shortcut. The easiest way to get a hotkey is to use Windows Explorer to create a shortcut and copy the hotkey settings used by the shortcut.

IconLocation

String

Path to file containing icons to use in shortcut.

TargetPath

String

Path of the application or document to execute.

WindowStyle

Integer

Type of Window to display application in. 1 for normal, 2 for minimized, and 3 for maximized Window.

WorkingDirectory

String

Default working directory for application to use.


Once you have set the parameters for the shortcut, invoke the 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 



Windows XP in a Nutshell
Windows XP in a Nutshell, Second Edition
ISBN: 0596009003
EAN: 2147483647
Year: 2003
Pages: 266

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net