VBScript: Create Shortcut (.lnk) File

Printer-friendly versionSend to friendPDF version
No votes yet

Following is a starting point for a script which will create a standard shortcut on the desktop.

  1. Set WshShell = CreateObject("WScript.Shell")
  2. strDesktop = WshShell.SpecialFolders("Desktop")
  3.  
  4. Set oShellLink = WshShell.CreateShortcut(strDesktop & "\My Shortcut.lnk")
  5. oShellLink.TargetPath = "" ' Absolute path to the executable, file, folder, or URL
  6. oShellLink.Arguments = "" ' Optional arguments to pass to the Target (usually for executables)
  7. oShellLink.WorkingDirectory = "" ' Usually set to the parent directory of the Target
  8. oShellLink.IconLocation = "" ' Optionally specify a specific icon to use
  9. oShellLink.Description = "" ' Short description, optional
  10. oShellLink.WindowStyle = "" ' 1 = Default, 3 = Maximized, 7 = Minimized
  11. oShellLink.Hotkey = "" ' Example: CTRL+SHIFT+K
  12. oShellLink.Save

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <hr> <span>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options