Home NT WSH

Wscript.CreateShortcut

Create or edit a Windows Shortcut

SYNTAX
      WscriptObject.CreateShortcut(sLinkFile)
      ShortcutObject.property = "Your Value"

Example

   sLinkFile = "C:\MyShortcut.LNK"
   Set oWS = WScript.CreateObject("WScript.Shell")
   Set oLink = oWS.CreateShortcut(sLinkFile)
   
   oLink.TargetPath = "C:\Program Files\MyApp\MyProgram.EXE"
   oLink.Arguments = ""
   oLink.Description = "MyProgram"
   oLink.HotKey = "ALT+CTRL+F"
   oLink.IconLocation = "C:\Program Files\MyApp\MyProgram.EXE, 2"
   oLink.WindowStyle = "1"
   oLink.WorkingDirectory = "C:\Program Files\MyApp"
   oLink.Save

Under Windows 2000, the 'Description' property corresponds to the "Comment" field that can be set when the properties of a Shortcut are viewed. The value of this property is also displayed in a tool-tip.

HotKey mappings are only usable if the shortcut is on the Desktop or in the Start Menu.
Valid hot key-options:
"ALT+", "CTRL+", "SHIFT+", and "EXT+".
"A" .. "Z", "0" .. "9", "Back", "Tab", "Clear", "Return", "Escape", "Space", and "Prior".

"Our life is frittered away by detail... simplify, simplify" - Henry David Thoreau

Related commands:

Arguments, display - WshArguments.Item
Q263324 - Shortcut Command truncates path names.

Equivalent Windows NT command:

SHORTCUT - Create a windows shortcut (.LNK file)



Back to the Top

Simon Sheppard
SS64.com