Get target path or file of a shortcut file (.lnk)

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 665
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Get target path or file of a shortcut file (.lnk)

Post by Grovkillen » Wed Dec 02, 2020 12:54 pm

Code: Select all

Let>SHORTCUT_FILE=C:\...\<file>.lnk

VBSTART
Function GetTargetFile(LinkFile)
  Set WShell = CreateObject("WScript.Shell")
  Set objShortcut = WShell.CreateShortcut(LinkFile)
  GetTargetFile = objShortcut.TargetPath
End Function
VBEND
VBEval>GetTargetFile("%SHORTCUT_FILE%"),TARGET_FILE
Trick found here: https://www.robvanderwoude.com/vbstech_shortcuts.php
Let>ME=%Script%

Running: 15.0.18
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts