Results 1 to 8 of 8

Thread: Resolve the target of a shortcut.lnk file? [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Resolve the target of a shortcut.lnk file? [RESOLVED]

    Does anyone have a simple (black box) routine that can accept the path/name of a shortcut link file and return it's target path/name?

    I want to be able to drag/drop desktop shortcuts onto a VB app that will then process the underlying target file that the shortcut points to.

    I've been searching, but everything I've found is very convoluted.

    Thanks, DaveBo
    Last edited by DaveBo; Sep 12th, 2003 at 08:37 AM.
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

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


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

  3. #3
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    try this:

    VB Code:
    1. Dim WS As Object
    2. Dim oShellLink As Object
    3.  
    4. Set WS = CreateObject("WScript.Shell")
    5. Set oShellLink = WS.CreateShortcut("C:\YOURsHORTCUT.lnk") 'all shotcuts end in .LNK
    6. MsgBox oShellLink.TargetPath
    7. Set WS = Nothing
    8. Set oShellLink = Nothing
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    WScript.Shell errors out

    Buggy,

    The line
    Set WS = CreateObject("WScript.Shell")
    gives an "automation error, the specified procedure could not be found"

    Do I need to add a reference? I tried adding all the "script"-like refs I could find but it still fails.

    Thanks, DaveBo
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    make a reference to Windows Scripting Host Model

    then this code:

    VB Code:
    1. Private Sub Form_Load()
    2. Dim WS As WshShell
    3. Dim oShellLink As WshShortcut
    4.  
    5. Set WS = New WshShell
    6. Set oShellLink = WS.CreateShortcut("C:\YOURsHORTCUT.lnk") 'all shotcuts end in .LNK
    7. MsgBox oShellLink.TargetPath
    8. Set WS = Nothing
    9. Set oShellLink = Nothing
    10. End Sub

    if you don't have the Windows Scripting Host Model then i dunno maybe your version of VB does not come with it.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  6. #6
    Member omfggaymod's Avatar
    Join Date
    Sep 2003
    Posts
    45

    intrasting

    anyone want to make a program that searchs for ink files and list there full path of the ink and then after it finds all the possable inks it will check to see if it works. if it dont then add to remove list but wont remove it unless wanted to. with the code bug submited(which is great, didnt know there was a option to do that) thanks bug!

    but still if anyone wants to work on a project like this i have msn so we can share desktops to see what each of us are doing and stuff like that. Also what would you rate a program skill like this?

    to me i think its begginer/intermediate not hard cuse its not really that hard if ya get stuck we can trust vb forums.




    -aymod/raymond

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Still fails

    The closest I could find in references was
    "Windows Script Host Object Model" wshom.ocx
    does that sound right?

    But at Set WS = New WshShell
    it returns "Automation error. The specified procedure could not be found."

    I'm using VB6 on a Win2000 machine right now. DaveBo
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Works fine on Windows98

    Just tried on a Win98 PC, same reference, and it works fine.

    Thanks, DaveBo
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

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