Shell.CreateShortcut

Shell.CreateShortcut ( 

string Folder,

string Description,

string Target,

string CmdLine = "",

string WorkingFolder = "",

string IconPath = "",

number IconIndex = 0,

number WindowMode = SW_SHOWNORMAL,

table  HotKey = nil,

string Comment = "" )

Description

Creates a shortcut on the user's system.

Note: If the target drive does not exist or cannot be accessed, the shortcut path folder will be truncated to eight characters. For more information, see Microsoft article Q263324.

Parameters

Folder

(string) The path to the folder where the shortcut will be created.

Description

(string) The label that will be given to the shortcut. This is the shortcut's "name"—i.e., what the user will see.

Target

(string) The full path and name of the file or folder that the shortcut will point to.

CmdLine

(string) The command line arguments (if any) that will be passed to the file linked by the shortcut.

WorkingFolder

(string) The working directory that will be used for the file pointed to by the shortcut.

IconPath

(string) The full path to a file containing the icon you want to use. The most common types are icon files (.ico) and executables (.exe). If no icon path is specified, the icon will be taken from the target file instead.

IconIndex

(number) The zero-based index describing which icon to use in the file. For example, an icon index of 2 means it will use the third icon in the file. If there is only one icon in the file, or if you want to use the first icon found, enter 0.

WindowMode

(number)  The run mode to use when it launches the file. Choose from:

CONSTANT

VALUE

DESCRIPTION

SW_SHOWNORMAL

1

The file will launch normally.

SW_MAXIMIZE

3

The file will launch maximized.

SW_SHOWMINNOACTIVE

7

The file will launch minimized.

HotKey

(table) A table containing an optional system-wide key combination that will launch the shortcut, indexed by the following keys:

KEY

TYPE

DESCRIPTION

shift

boolean

Whether the "shift" modifier key was held down as part of the key combination. The value true means it was held down and false means it wasn't. This value can be accessed using tb.shift.

ctrl

boolean

Whether the "ctrl" modifier key was held down as part of the key combination. The value true means it was held down and false means it wasn't. This value can be accessed using tb.ctrl.

alt

boolean

Whether the "alt" modifier key was held down as part of the key combination. The value true means it was held down and false means it wasn't. This value can be accessed using tb.alt.

keycode

number

The virtual key code of the key that was pressed. This value can be accessed using tb.keycode.

Note: If you do not want to assign a hotkey for the shortcut, nil should be passed (nil is the default value).

Comment

(string) An optional string to display in the "comment" section of the shortcut. This parameter is only supported on Windows 2000, Windows XP, Windows Vista or later. On operating systems that do not support the information, it will be ignored.

Returns

Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

See also:  Related Actions