The form disappears when you try to create a VB.NET shortcut

When my code reaches the line Dim MyShortcut..., the form disappears, the exception does not cause the window error reporting the form to just disappear with the ongoing process.

Friend Sub CreateShortcut(Location As String, Target As String)
    Dim MyShortcut As IWshRuntimeLibrary.IWshShortcut = CType((New IWshRuntimeLibrary.WshShellClass).CreateShortcut(Location), IWshRuntimeLibrary.IWshShortcut)
    MyShortcut.TargetPath = Target
    MyShortcut.Save()
End Sub

Ask if you need more information. I was not sure what might cause the problem, so I did not know what else to add.

Thanks in advance!

+3
source share

All Articles