Differences
This shows you the differences between two versions of the page.
windows_wiki:vbscript_-_create_shortcut [2014/11/24 22:47] billdozor |
windows_wiki:vbscript_-_create_shortcut [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== VBScript - Create Shortcut ====== | ||
- | A vbscript template to create a shortcut. | ||
- | <code vb file create_shortcut.vbs> | ||
- | ' | ||
- | ' VBScript: | ||
- | ' NAME: < | ||
- | ' DESCRIPTION: | ||
- | ' | ||
- | |||
- | ' | ||
- | Option Explicit | ||
- | Dim Shell, FileSys ' | ||
- | Dim ShortCut 'used to set properties of the shortcut. Comes from using createShortCut | ||
- | Dim LinkTarget 'Path to executable | ||
- | Dim LinkArgs ' | ||
- | Dim LinkLocation 'Place to put shortcut | ||
- | Dim LinkName 'Name of shortcut | ||
- | Dim LinkDescription ' | ||
- | Dim LinkIcon ' | ||
- | set Shell = CreateObject(" | ||
- | set FileSys = CreateObject(" | ||
- | |||
- | ' | ||
- | '-- Enter Full Path to Executable for shortcut to reference -- | ||
- | LinkTarget = " | ||
- | |||
- | '-- Enter Shortcut arguments -- | ||
- | LinkArgs = "" | ||
- | |||
- | '-- Enter Location to put shortcut -- | ||
- | LinkLocation = Shell.SpecialFolders(" | ||
- | '(or: full path to location, " | ||
- | |||
- | '-- Enter Name for Shortcut (must begin with \ and end in .lnk) -- | ||
- | LinkName = " | ||
- | |||
- | '-- Enter Shortcut Description -- | ||
- | LinkDescription = " | ||
- | |||
- | '-- Enter Shortcut Icon -- | ||
- | LinkIcon = LinkTarget | ||
- | '(or: " | ||
- | ' | ||
- | |||
- | 'If shortcut already exists, quit and don't create it | ||
- | If FileSys.FileExists(LinkLocation & LinkName) Then | ||
- | Wscript.Quit | ||
- | End If | ||
- | |||
- | ' | ||
- | set ShortCut = Shell.CreateShortcut(LinkLocation & LinkName) | ||
- | |||
- | 'Set Shortcut Properties | ||
- | ShortCut.TargetPath = LinkTarget | ||
- | ShortCut.Arguments = LinkArgs | ||
- | ShortCut.IconLocation = LinkIcon | ||
- | ShortCut.description = LinkDescription | ||
- | ShortCut.Save | ||
- | </ |