0

Let's say I have a nethood link to a folder with the name "BLABLA" and the target path is "\\servername\temp"

how do I get the string for the target path? I tried:

Set oShell = CreateObject("WScript.Shell")
Const NET_HOOD = &H13&
Set oShApp = CreateObject("Shell.Application")
sNetHood = oShApp.NameSpace(NET_HOOD).Self.Path
Set oShortCut = oShell.CreateShortcut(sNetHood & "\" & "BLABLA" & ".lnk")

MsgBox "> " & oShortCut.TargetPath

It does everything, even creates a oShortCut object without any errors. But, it does not return

oShortCut.TargetPath

what am I doing wrong?

I'd like it to return this: "\\servername\temp\BLABLA"
Thanks in advance for any advice!

I've created the shortcut under win 7 with right click in Computer view of the explorer and then > Add a network location > Next ... etc. It creates a Folder representing a shortcut in NetHood to the path on the server ... it's like a mapped share but not really it.

nivoe
  • 405
  • 1
  • 4
  • 11
  • btw. the read only methods oShortCut.FullName works like a charm ... returning the utterly useless relative path to the link – nivoe Jul 23 '13 at 15:24
  • Give a look at that one on SO esp. that second answer with code for Win32_LogicalDisk http://stackoverflow.com/questions/7336685/mapping-a-network-drive-and-checking-for-its-existence-in-vbscript – Papasmile Jul 23 '13 at 16:38
  • returns only the mapped shares ... but not the folder shortcuts' target paths – nivoe Jul 24 '13 at 12:10

1 Answers1

-1

thx for the input ... after years of reading myself into the matter and then checking google once more i found a c# code which i wrote into vbs and then simplified only to see that all i had to change in the end was to add this:

.GetLink

so the solution to my problem is:

Const NET_HOOD = &H13&
Set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.NameSpace(NET_HOOD)

For Each oFile In oFolder.Items
    MsgBox oFile.GetLink.Path
Next
nivoe
  • 405
  • 1
  • 4
  • 11