.CreateShortcut

Create or edit a Windows Shortcut

Syntax
      objShell.CreateShortcut(strLinkFile)
      ShortcutObject.property = "Your Value"

Key
   objShell   A WScript.Shell object
   ShortcutObject  An existing shortcut object

Example

   Set objShell = WScript.CreateObject("WScript.Shell")
   Set lnk = objShell.CreateShortcut("C:\MyShortcut.LNK")
   
   lnk.TargetPath = "C:\Program Files\MyApp\MyProgram.EXE"
   lnk.Arguments = ""
   lnk.Description = "MyProgram"
   lnk.HotKey = "ALT+CTRL+F"
   lnk.IconLocation = "C:\Program Files\MyApp\MyProgram.EXE, 2"
   lnk.WindowStyle = "1"
   lnk.WorkingDirectory = "C:\Program Files\MyApp"
   lnk.Save
   'Clean up 
Set lnk = Nothing Similarly in Powershell: $objShell = New-Object -ComObject WScript.Shell $lnk = $objShell.CreateShortcut("$home\Desktop\DemoShortcut.lnk") $lnk.TargetPath = "C:\demo.exe" $lnk.Save()

The 'Description' property corresponds to the shortcut "Comment" field, this will be 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:

Arguments, display - WshArguments.Item
Q263324 - Shortcut Command truncates path names.
Equivalent Windows CMD command: SHORTCUT - Create a windows shortcut (.LNK file)


© Copyright SS64.com 1999-2014
Some rights reserved