|
-
Sep 8th, 2003, 08:27 AM
#1
Thread Starter
Hyperactive Member
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
-
Sep 8th, 2003, 04:40 PM
#2
-
Sep 8th, 2003, 09:23 PM
#3
The picture isn't missing
try this:
VB Code:
Dim WS As Object
Dim oShellLink As Object
Set WS = CreateObject("WScript.Shell")
Set oShellLink = WS.CreateShortcut("C:\YOURsHORTCUT.lnk") 'all shotcuts end in .LNK
MsgBox oShellLink.TargetPath
Set WS = Nothing
Set oShellLink = Nothing
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Sep 9th, 2003, 08:17 AM
#4
Thread Starter
Hyperactive Member
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
-
Sep 11th, 2003, 11:57 PM
#5
The picture isn't missing
make a reference to Windows Scripting Host Model
then this code:
VB Code:
Private Sub Form_Load()
Dim WS As WshShell
Dim oShellLink As WshShortcut
Set WS = New WshShell
Set oShellLink = WS.CreateShortcut("C:\YOURsHORTCUT.lnk") 'all shotcuts end in .LNK
MsgBox oShellLink.TargetPath
Set WS = Nothing
Set oShellLink = Nothing
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  .
-
Sep 12th, 2003, 02:29 AM
#6
Member
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
-
Sep 12th, 2003, 08:23 AM
#7
Thread Starter
Hyperactive Member
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
-
Sep 12th, 2003, 08:36 AM
#8
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|