WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: kdmoyers on August 14, 2024, 05:22:44 AM

Title: fun with shortcut .lnk files
Post by: kdmoyers on August 14, 2024, 05:22:44 AM
I needed my program to follow a possible shortcut .lnk redirection, and was pleased to find that Winbatch has my back with the ShortCutInfo function:

   ;=== address the possibility that param1 is actually a Windows "shortcut" file ===
   errormode(@off)
   scinfo = shortcutinfo(param1)         ; attempt to interpret as a "shortcut"
   errormode(@on)
   if itemcount(scinfo,@tab)>1            ; is a list?
      display(1,"shortcut redirecting From",param1)
      param1 = itemextract(1,scinfo,@tab)   ; 1st element is target filename
      display(2,"shortcut redirecting To",param1)
   endif