Advertisement
ASP_Volume2 Files/ File Controls/ Input/ Output #26001

Get Shortcut's Target

After looking all over on PSC i was unable to find Short, Simple and Clean code to get the target path of a window's shortcut (.lnk) file, so here is an easier way.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Public Function GetTarget(strPath As String) As String
  'Gets target path from a shortcut file
On Error GoTo Error_Loading
  
  Dim wshShell As Object
  Dim wshLink As Object
  
  Set wshShell = CreateObject("WScript.Shell")
  Set wshLink = wshShell.CreateShortcut(strPath)
  GetTarget = wshLink.TargetPath
  
  Set wshLink = Nothing
  Set wshShell = Nothing
  
  Exit Function
  
Error_Loading:
  GetTarget = "Error occured."
End Function
Original Comments (3)
Recovered from Wayback Machine