|
-
Mar 1st, 2013, 10:31 AM
#1
Thread Starter
Lively Member
Creating ShortCut
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:
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
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???
-
Mar 1st, 2013, 11:11 AM
#2
Re: Creating ShortCut
What happens if you were to compile the app as ApplicationGrid.exe rather than Application Grid.exe ? Thinking the space may be the issue. It is against my better judgement to use a space in an application name so I can't say if this is it or not.
-
Mar 1st, 2013, 11:17 AM
#3
Thread Starter
Lively Member
Re: Creating ShortCut
Nope. Still does not work...
-
Mar 1st, 2013, 11:34 AM
#4
Re: Creating ShortCut
Evidently what you get from the file is not what you think it is. I notice that you're using streamreader ReadToEnd so is it possible that there's a stray character at the end of the line (a carriage return or a space?) It's very easily checked. Just put in a line like ...
If FilePath <> "C:\Users\Marek\Desktop\Application Grid.exe" Then MsgBox("See! Told you so!")
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Mar 1st, 2013, 11:34 AM
#5
Re: Creating ShortCut
I don't see you call the CreateShortCut sub anywhere in your code....
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Mar 1st, 2013, 11:44 AM
#6
Thread Starter
Lively Member
Re: Creating ShortCut
Ok.. I forgot to add at the forum :P
Code:
CreateShortCut(OldPath)
And thanks dunfiddlin! I pressed Enter as I allways do when I finnish off typing, and I did not know that it takes ENTER space as character Thanks!
-
Mar 1st, 2013, 12:31 PM
#7
Thread Starter
Lively Member
Re: Creating ShortCut
Thats ok, It was my typing fault... :P
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|