I just made an Sub called CreateShortcut and it should 100% work... And I even figured out the problem, but I have no idea how to fix it.
Code:
The path to File is in the text file that you saw me "Reading". The path in the text file is just simple "C:\Users\Marek\Desktop\Application Grid.exe". If I replace FilePath in CreateShortcut Sub, with this path, it works! Why it does this???Code:Dim UserName As String = Environment.UserName Dim Path As String = "C:\Users\" & UserName & "\AppData\Roaming\AppHolder" Dim ShortcutDirectory As String = "C:\Users\" & UserName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\" Dim OldPath As String = "C:\Users\" & UserName & "\AppData\Roaming\AppHolder\Updating\PathToProgram.txt" Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim StreamReader As System.IO.StreamReader = New System.IO.StreamReader(OldPath) OldPath = StreamReader.ReadToEnd End Sub Private Sub CreateShortCut(ByVal FilePath As String) Try Dim Shortcut As IWshShortcut Dim Wsh As New WshShell Shortcut = CType(Wsh.CreateShortcut(ShortcutDirectory & "Application Holder.lnk"), IWshShortcut) With Shortcut .TargetPath = FilePath .Description = "Description?" .IconLocation = FilePath & ", 0" .Save() End With Catch Excep As Exception Debug.WriteLine(TimeString) Debug.WriteLine(Excep.Message) Stop End Try End Sub




Reply With Quote