windows_wiki:vbscript_-_create_shortcut

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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:  AUTHOR: Bill Howe 11/15/2011 
-' NAME: <CreateShortCut.vbs> 
-' DESCRIPTION: Uses wscript.shell to create a shortcut.  
-'========================================================================== 
- 
-'Declare Variables for later use 
-Option Explicit 
-Dim Shell, FileSys 'instance of the Shell, FileSystem object 
-Dim ShortCut 'used to set properties of the shortcut. Comes from using createShortCut 
-Dim LinkTarget 'Path to executable 
-Dim LinkArgs 'Arguments sent to executable 
-Dim LinkLocation 'Place to put shortcut 
-Dim LinkName 'Name of shortcut 
-Dim LinkDescription 'Description of shortcut (shows up on mouse hover) 
-Dim LinkIcon 'Location of the shortcut icon 
-set Shell = CreateObject("WScript.Shell") 'Create Shell Object 
-set FileSys = CreateObject("Scripting.FileSystemObject") 'Create FileSystem Object 
- 
-'++++++++++++++++++++++++ EDIT THESE VARIABLES +++++++++++++++++++++++++++++ 
-'-- Enter Full Path to Executable for shortcut to reference -- 
-LinkTarget = "C:\Program Files (x86)\Program.exe" 
- 
-'-- Enter Shortcut arguments -- 
-LinkArgs = "" 
- 
-'-- Enter Location to put shortcut -- 
-LinkLocation = Shell.SpecialFolders("Desktop") 
-'(or: full path to location, "C:\Users\Robert\Desktop") 
- 
-'-- Enter Name for Shortcut (must begin with \ and end in .lnk) -- 
-LinkName = "\ShortcutName.lnk" 
- 
-'-- Enter Shortcut Description -- 
-LinkDescription = "Shortcut Description Here" 
- 
-'-- Enter Shortcut Icon -- 
-LinkIcon = LinkTarget 
-'(or: "%SystemRoot%\system32\SHELL32.dll,x" where x is the icon number) 
-'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
- 
-'If shortcut already exists, quit and don't create it 
-If FileSys.FileExists(LinkLocation & LinkName) Then 
-  Wscript.Quit 
-End If 
- 
-'Create ShortCut 
-set ShortCut = Shell.CreateShortcut(LinkLocation & LinkName) 
- 
-'Set Shortcut Properties 
-ShortCut.TargetPath = LinkTarget  
-ShortCut.Arguments = LinkArgs 
-ShortCut.IconLocation = LinkIcon 
-ShortCut.description = LinkDescription 
-ShortCut.Save 
-</code> 
  • windows_wiki/vbscript_-_create_shortcut.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)