Results 1 to 13 of 13

Thread: how to update an existing desktop shortcut?

  1. #1

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    how to update an existing desktop shortcut?

    How do I update or change the target of an existing desktop shortcut when my application runs using VB6.
    He who never made a mistake never made a discovery?

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: how to update an existing desktop shortcut?

    This might help

  3. #3

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: how to update an existing desktop shortcut?

    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?
    He who never made a mistake never made a discovery?

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: how to update an existing desktop shortcut?

    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.
    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 )

  5. #5

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: how to update an existing desktop shortcut?

    I tried this and it created a new short cut. I am not sure what part just does the updating?
    VB Code:
    1. 'modify flash shortcut on desktop
    2.     Dim strGroupName As String, strLinkName As String
    3.     Dim strLinkPath As String, strLinkArguments As String
    4.     Dim fPrivate As Boolean, sParent As String
    5.     Dim fSuccess As Boolean
    6.  
    7.     strLinkName = "Agent Prospecting Presentation"
    8.     strLinkPath = "c:\MyWestfieldPresentation\Westfield_1to1F_v1.exe"
    9.     strLinkArguments = ""
    10.     fPrivate = True                              ' Add shortcut to desktop.
    11.     strGroupName = "..\..\Desktop"
    12.     sParent = "$(Programs)"
    13.     fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & vbNullChar, fPrivate, sParent)
    He who never made a mistake never made a discovery?

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: how to update an existing desktop shortcut?

    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

  7. #7

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: how to update an existing desktop shortcut?

    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.
    He who never made a mistake never made a discovery?

  8. #8
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: how to update an existing desktop shortcut?

    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?

  9. #9

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: how to update an existing desktop shortcut?

    Yep, I two shortcuts with the same name on the desktop. The properties are different but they have the same name.
    He who never made a mistake never made a discovery?

  10. #10
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: how to update an existing desktop shortcut?

    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.

  11. #11

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    Re: how to update an existing desktop shortcut?

    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:
    1. If strLinkName = "Agent Prospecting Presentation" Then
    2.     Kill "c:\MyWestfieldPresentation\Westfield_1to1F_v1.exe"
    3. Else
    4.     strLinkName = "Agent Prospecting Presentation"
    5.     strLinkPath = "c:\MyWestfieldPresentation\Westfield_1to1F_v1.exe"
    6.     strLinkArguments = ""
    7.     fPrivate = True                              ' Add shortcut to desktop.
    8.     strGroupName = "..\..\Desktop"
    9.     sParent = "$(Programs)"
    10.     fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & vbNullChar, fPrivate, sParent)
    11.  
    12.  End If
    He who never made a mistake never made a discovery?

  12. #12
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: how to update an existing desktop shortcut?

    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

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to update an existing desktop shortcut?

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width