Microsoft® Windows® Script Host
CreateShortcut Method
WSH Reference
Version 1

See Also                      Applies To


Description
Creates an object reference to a shortcut or URLshortcut.
Syntax
object.CreateShortcut(strPathname)
Parameters
Part Description
object WshShell object.
strPathname Path and file name of the shortcut being created.
Remarks
The CreateShortcut method creates a WshShortcut object and returns it. This method can be used to create a new shortcut or open an existing one to modify its properties. A Windows shortcut must have the extension ".lnk". If the shortcut title ends with ".url", a WshURLShortcut object is created.

Example
The following examples create a shortcut to the currently executing script and a URL shortcut to www.microsoft.com.

Set WshShell = WScript.CreateObject("WScript.Shell")
Set oShellLink = WshShell.CreateShortcut("Current Script.lnk")
oShellLink.TargetPath = WScript.ScriptFullName
oShellLink.Save

Set oUrlLink = WshShell.CreateShortcut("Microsoft Web Site.URL")
oUrlLink.TargetPath = "http://www.microsoft.com"
oUrlLink.Save