I want to be able to search to see if a shortcut to an executable file exists. This is the code that I have. The thing is that the shortcut exists but it always send me false when it search for the path.
Thanks..
Public Function FileExists(FileName As String) As Boolean
If Dir(FileName) = "" Then
FileExists = False
Else
FileExists = True
End If
End Function
Private Sub Form_Load()
fDeleteShortcutOnDesktop
End Sub
Sub fDeleteShortcutOnDesktop()
Dim WSHShell As IWshRuntimeLibrary.IWshShell_Class
Dim WSHShortcut As IWshRuntimeLibrary.IWshShortcut_Class
Dim strFullFilePathName As String
Dim strDesktopPath As String
Dim strFileName As String
Dim strPath As String
' Create a Windows Shell Object
Set WSHShell = New IWshRuntimeLibrary.IWshShell_Class
' Read desktop path using WshSpecialFolders object
strDesktopPath = WSHShell.SpecialFolders.Item("Desktop"
strDesktopPath = strDesktopPath & "\" & gstrApplicationName & ".dat"
If FileExists(strDesktopPath) = True Then
'delete
End If
Set WSHShell = Nothing
End Sub
Thanks..
Public Function FileExists(FileName As String) As Boolean
If Dir(FileName) = "" Then
FileExists = False
Else
FileExists = True
End If
End Function
Private Sub Form_Load()
fDeleteShortcutOnDesktop
End Sub
Sub fDeleteShortcutOnDesktop()
Dim WSHShell As IWshRuntimeLibrary.IWshShell_Class
Dim WSHShortcut As IWshRuntimeLibrary.IWshShortcut_Class
Dim strFullFilePathName As String
Dim strDesktopPath As String
Dim strFileName As String
Dim strPath As String
' Create a Windows Shell Object
Set WSHShell = New IWshRuntimeLibrary.IWshShell_Class
' Read desktop path using WshSpecialFolders object
strDesktopPath = WSHShell.SpecialFolders.Item("Desktop"
strDesktopPath = strDesktopPath & "\" & gstrApplicationName & ".dat"
If FileExists(strDesktopPath) = True Then
'delete
End If
Set WSHShell = Nothing
End Sub