;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       GetShortcutProperties() 
;; 
;;ACTION         Returns a specific shortcut property, or an array of all properties 
;; 
;;AUTHOR         Allen Powell 
;; 
;;CONTRIBUTORS   Glenn Barnas (cleanup/adaptation) 
;; 
;;VERSION        1.0  - 2007/11/08 
;; 
;;HISTORY        1.0  - 2007/11/08 - Initial Release 
;; 
;;SYNTAX         GetShortcutProperties(File [, Property]) 
;; 
;;PARAMETERS     File - REQUIRED - String 
;;               - Fully Qualified File Name 
;; 
;;		 Property - OPTIONAL - String 
;;               - name of specific property to return 
;; 
;;REMARKS         
;; 
;;RETURNS        Array of all properties or Variant containing a single property. 
;;               Variant with single property if property is requested, otherwise 
;;		 returns an Array with all 8 property values 
;; 
;;DEPENDENCIES   WSH 
;; 
;;TESTED WITH    W2K, WXP, W2K3, Vista 
;; 
;;EXAMPLES       GetShortcutProperties('C:\Users\username\Desktop\MyDesktop.lnk', 'StartIn') ? 
;;		 $a = GetShortcutProperties('C:\Users\username\Desktop\MyDesktop.lnk')  
;;		 For Each $ in $a 
;;		  $ ? 
;;		 Next 
; 
Function GetShortcutProperties($_FqFn, OPTIONAL $_Property)
 
  Dim $_oShell				; shell object pointer 
  Dim $_iShortcut			; shortcut item in shell object array 
  Dim $_aTmp[7]				; temp array 
 
  ; Verify that the defined shortcut is present 
  If Exist($_FqFn)
 
    $_oShell = CreateObject("wscript.shell")
 
    If $_oShell
      $_iShortcut = $_oShell.CreateShortcut($_FqFn)	; get properties 
 
      ; place all properties into an array 
      $_aTmp[0] = $_iShortcut.Description
      $_aTmp[1] = $_iShortcut.targetpath
      $_aTmp[2] = $_iShortcut.workingdirectory
      $_aTmp[3] = $_iShortcut.Iconlocation
      $_aTmp[4] = split($_iShortcut.Iconlocation,",")[0]
      $_aTmp[5] = split($_iShortcut.Iconlocation,",")[1]
      $_aTmp[6] = $_iShortcut.Arguments
      $_aTmp[7] = $_iShortcut.windowstyle
 
      ; return a specific property if requested, otherwise return the array of all properties 
      If $_Property
        Select
         Case $_Property = "Description"
          $GetShortcutProperties = $_aTmp[0]
         Case $_Property = "Path" or $_Property = "Target"
          $GetShortcutProperties = $_aTmp[1]
         Case $_Property = "Startin" or $_Property = "WorkingDirectory"
          $GetShortcutProperties = $_aTmp[2]
         Case $_Property = "Icon"
          $GetShortcutProperties = $_aTmp[3]
         Case $_Property = "IconLocation"
          $GetShortcutProperties = $_aTmp[4]
         Case $_Property = "IconIndex"
          $GetShortcutProperties = $_aTmp[5]
         Case $_Property = "Arguments"
          $GetShortcutProperties = $_aTmp[6]
         Case $_Property = "Style" or "Run"
          $GetShortcutProperties = $_aTmp[7]
        EndSelect
      Else	; no property 
        $GetShortcutProperties = $_aTmp
      EndIf	; property 
 
    Else	; shell shortcut failed 
      Exit @ERROR	; return shell instantiation error 
    EndIf	; shell ? 
  Else
    Exit 2	; file not found 
  EndIf		; file ? 
 
  Exit 0		; return success 
 
EndFunction