How do I update or change the target of an existing desktop shortcut when my application runs using VB6. :)
Printable View
How do I update or change the target of an existing desktop shortcut when my application runs using VB6. :)
This might help
I think this is helpful, but I am not creating the shortcut with VB, the shortcut already exist. I just want to modify the existing short using VB.
How would I do that using eny of those examples?
you have to scroll down to the bottom for more information (which is normally hidden - that's the reason i've linked to google's page cache :) )Quote:
If you call the same process again with a different path, it will modify the existing shortcut rather than create a new one, providing that the name of the shortcut does NOT change.
I tried this and it created a new short cut. I am not sure what part just does the updating?
VB Code:
'modify flash shortcut on desktop Dim strGroupName As String, strLinkName As String Dim strLinkPath As String, strLinkArguments As String Dim fPrivate As Boolean, sParent As String Dim fSuccess As Boolean strLinkName = "Agent Prospecting Presentation" strLinkPath = "c:\MyWestfieldPresentation\Westfield_1to1F_v1.exe" strLinkArguments = "" fPrivate = True ' Add shortcut to desktop. strGroupName = "..\..\Desktop" sParent = "$(Programs)" fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & vbNullChar, fPrivate, sParent)
if a shortcut called "Agent Prospecting Presentation" already exists on the desktop then it just replaces it with the link you specified instead of creating a new one.
if you have a shortcut "Agent Prospecting Presentation" which links to "C:\windows\notepad.exe" and then run your code it'll replace it
But thats not what happened. My shortcut already exist on the desktop. It's currently pointing to a different exe. When I ran the code it created a new shortcut, so now I have 2 shortcuts on the desktop. :eek:
that's strange, it works perfectly for me.
so are you saying that you have two shortcuts on your desktop with exactly the same name?
Yep, I two shortcuts with the same name on the desktop. The properties are different but they have the same name.
well i've got no explanation for that. what OS are you using, I'm running XP.
Perhaps you should just check for the shortcut, delete it and then make your new one.
I am also running WinXP, but I was installing my app on a Win2000 OS. I don't think that would make any difference.
Deleting one and then making a new one would be accaptable. Is this the correct whay to do that?
VB Code:
If strLinkName = "Agent Prospecting Presentation" Then Kill "c:\MyWestfieldPresentation\Westfield_1to1F_v1.exe" Else strLinkName = "Agent Prospecting Presentation" strLinkPath = "c:\MyWestfieldPresentation\Westfield_1to1F_v1.exe" strLinkArguments = "" fPrivate = True ' Add shortcut to desktop. strGroupName = "..\..\Desktop" sParent = "$(Programs)" fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & vbNullChar, fPrivate, sParent) End If
That would delete your .exe. You just want to delete the link on the dektop 'Agent Prospecting Presentation.lnk'
Presumably you'd have to find the location of the user's desktop first, so you can kill the link - Finding Special Folders
This should help allot - http://www.vbforums.com/showthread.php?t=322799 :)