Forum Discussion
AlexanderM
13 years agoStaff
Hi Louis-Philippe,
Here is a script based on the How To sample that demonstrates how to validate the target path of a shortcut on the Desktop:
Sub Test
If (Not IsShortcutValid("ShortcutName")) Then
Call Log.Error("Shortcut is not valid")
Exit Sub
End If
Call Log.Message("Shortcut is valid")
End Sub
Function IsShortcutValid(shortcutName)
Dim WshShell, fso, startDir, path, shortcut
Set WshShell = CreateObject("WScript.Shell")
startDir = WshShell.SpecialFolders("Desktop") & "\"
path = startDir & "\" & shortcutName & ".lnk"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(path) Then
Set shortcut = WshShell.CreateShortcut(path)
IsShortcutValid = fso.FileExists(shortcut.TargetPath)
Exit Function
End If
IsShortcutValid = False
End Function
Related Content
- 2 years agonaveens33_
- 6 years agopebot
- 6 years agoLucian