Dim objShell, objFSO, CleanPath, fileFolder
Dim userFolder, desktopFolder, custFolder, extension
Dim fullname, shortcut, shortTarget
Dim WshS
Set WshS = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
'Expand Environment
'Create const's to spare time and place
usrProfile = WshS.ExpandEnvironmentStrings("%UserProfile%")
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set searchFolder = objFSO.GetFolder(usrProfile & "\AppData\Roaming\Microsoft\Windows\Recent")
Set custFolder = searchFolder.Files
For Each custFile in custFolder
extension = objFSO.GetExtensionName(LCase(custFile.name))
If extension = "lnk" then
'Find full path of target within shortcut
fullname = objFSO.GetAbsolutePathName(custFile)
'See http://www.devguru.com/Technologies/wsh/quickref/wshshell_CreateShortcut.html
'for more information on how this works.
Set shortcut = objShell.CreateShortcut(fullname)
shortTarget = shortcut.TargetPath
Dim myFileToDelete
CleanPath = "F:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "G:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "H:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "I:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "J:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "K:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "L:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "M:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "N:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "O:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "P:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "Q:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "R:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "S:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "T:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "U:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "V:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "W:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "X:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "Y:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
CleanPath = "Z:\"
If InStr(shortTarget, CleanPath) then
Set myFileToDelete = objFSO.GetFile(fullname)
myFileToDelete.Delete
End If
End If
Next