Create a shortcut via script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  'Create Shortcut

    Option Explicit
    Dim objShell, objDesktop, objLink
    Dim strAppPath, strWorkDir, strIconPath
 
    strWorkDir =""
    strAppPath = "\\Servername\share\somefolder\some.exe"
    strIconPath = "%SystemRoot%\system32\SHELL32.dll,158"
 
    Set objShell = CreateObject("WScript.Shell")
    objDesktop = objShell.SpecialFolders("AllUsersDesktop")
    Set objLink = objShell.CreateShortcut(objDesktop & "\MyNewLink.lnk")
 
    objLink.Description = "Shortcut Description"
    objLink.HotKey = "CTRL+SHIFT+O"
    objLink.IconLocation = strIconPath 
    objLink.TargetPath = strAppPath
    objLink.WindowStyle = 3
    objLink.WorkingDirectory = strWorkDir
    objLink.Save

Leave a Reply