06-17-2010, 09:50 AM
All you need to do is - write a WMI query that includes the path of the folder you want to check as well as the file extension for shortcuts i.e 'lnk'
e.g this script checks if Quick Test Professional shortcut exist in folder "C:\Test\Shortcuts"
e.g this script checks if Quick Test Professional shortcut exist in folder "C:\Test\Shortcuts"
Code:
strComputer = "."
strFolder = "\\Test\\Shortcuts\\"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * From Cim_DataFile Where Path = '" & strFolder & "' AND Drive = 'C:' And Extension = 'lnk'")
For Each objItem in colItems
If objItem.FileName = "QuickTest Professional" Then
msgbox "Shortcut Exists"
End If
Next