John Topley's Knowledgebase

Creating A Shortcut

Friday, 30 May 2003

This Windows Script Host script illustrates the creation of a shortcut on the Windows desktop.

Download CreateShortcut.vbs

' Script to illustrate shortcut (shell link) creation.
' Creates a shortcut to the Windows Calculator on the desktop
' and sets up a shortcut key.
Option Explicit
Private strDesktop
Private obkShellLink
Private wshShell

Set wshShell = WScript.CreateObject("WScript.Shell")
strDesktop = wshShell.SpecialFolders("Desktop")
Set objShellLink = wshShell.CreateShortcut(strDesktop & "\WSH-Created Shortcut.lnk")

With objShellLink
 .TargetPath = wshShell.ExpandEnvironmentStrings ("%WINDIR%\system32\calc.exe")
 .WindowStyle = 4
 .HotKey = "CTRL+SHIFT+C"
 .IconLocation = "calc.exe, 0"
 .WorkingDirectory = strDesktop
 .Save
End With

Set objShellLink = Nothing
Set wshShell = Nothing

top | index | previous | next | comments ()

home | archive | kb | media | about | contact | accessibility
Copyright © 2003 - 2005 John Topley. Made with CityDesk.