I'm trying to delete an old desktop shortcut on program startup. Only this code isn't working.

        ' Get rid of the updater icon on the desktop. 
        Dim DeleteShortcut As String
        DeleteShortcut = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Sample Shortcut.lnk"
        If System.IO.File.Exists(DeleteShortcut) = True Then
        End If

Looks pretty straight forward- but just not working. Is there another way to do this?

I also tried-

        ' Get rid of the updater icon on the desktop. 
        If System.IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Sample Shortcut.lnk") Then
            System.IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Sample Shortcut.lnk")
        End If

It's got to do with my path. I put in a message box after THEN but nothing came up.

Edited 3 Years Ago by RobRTaylor

Your code will work if the .lnk file is in the current users desktop directory. But if it's in the All Users desktop Directory, you'll need to use Environment.SpecialFolder.CommonDesktopDirector.

This question has already been answered. Start a new discussion instead.