Results 1 to 8 of 8

Thread: Get Target Path Of Shortcut

  1. #1

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Get Target Path Of Shortcut

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     MsgBox GetTargetPath("ShortCut Filename")
    5. End Sub
    6.  
    7. Function GetTargetPath(ByVal FileName As String)
    8.  
    9. Dim Obj As Object
    10. Set Obj = CreateObject("WScript.Shell")
    11.  
    12. Dim Shortcut As Object
    13. Set Shortcut = Obj.CreateShortcut(FileName)
    14. GetTargetPath = Shortcut.TargetPath
    15. Shortcut.Save
    16.  
    17. End Function


    Has someone helped you? Then you can Rate their helpful post.

  2. #2
    Addicted Member
    Join Date
    May 2004
    Location
    Nagpur, India
    Posts
    228

    Re: Get Target Path Of Shortcut

    2 problems with the above:
    1. Not sure which file, but installing McAfee deletes some file and
    Set Obj = CreateObject("WScript.Shell")
    never works!.
    2. McAfee detects this as a scritpting going on and prompts for allowing it.

    Is there any other way?

  3. #3

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Get Target Path Of Shortcut

    Have a look at RobDog888's code here : http://www.vbforums.com/showthread.php?t=322799

    It might work, I don't know...


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    Addicted Member
    Join Date
    May 2004
    Location
    Nagpur, India
    Posts
    228

    Re: Get Target Path Of Shortcut

    I didnt check it further but it also uses shell technique.
    Scripting etc is "caught" by McAfee \Norton etc and it is a point of concern because home users trust anti-virus programs more than my program

    May be some workaround to find the short-cut target not using shell or scripting.

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

    Re: Get Target Path Of Shortcut

    Actually my code example uses the Shell32.dll This is different from Windows Scripting Host.
    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

  6. #6
    Addicted Member
    Join Date
    May 2004
    Location
    Nagpur, India
    Posts
    228

    Re: Get Target Path Of Shortcut

    1 more problem.
    If there are 2 operating system, say windows 98 on C drive and windows XP on drive D, then checking the shortcuts created with Windows XP and not properly handled in our application running on say Windows 98.

    I do this:
    1. Run the application in windows 98.
    2. Try to open the shortcut created in Windows XP.
    3. The path returned is always C:\ something. Actually it should be D:\ something

  7. #7
    New Member
    Join Date
    Apr 2008
    Posts
    2

    Re: Get Target Path Of Shortcut

    i am trying to do the same exact thing in c++ can anyone help with this? please thank you,.

  8. #8
    Lively Member Amerigo's Avatar
    Join Date
    Dec 2008
    Location
    PSR B1620-26 c-1
    Posts
    126

    Re: Get Target Path Of Shortcut

    This worked great for me. Thank you ever so much, manavo11!
    Anyone who does not wonder, is either omnipotent or a fool.
    Amerigoware <<<My Projects

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