dantefs
dantefs

Reputation: 174

How to list the target path of all My Network Places in vbs?

I want a script to list a users My Network Places in Windows XP. There are lots of examples on the web that show how to get the Name of each location, but I want the target path (i.e. the server name / folder that the link is pointing at).

To get the name I can do:

Const MY_NETWORK_PLACES = &H12&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_NETWORK_PLACES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

How do I get the target path? Looking at .Path gives me the local path of the shortcut.

Upvotes: 1

Views: 309

Answers (1)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38745

Use .GetLink.Path:

If objItem.IsFileSystem Then
   Wscript.Echo objItem.Name, " =>", objItem.GetLink.Path
End If

Upvotes: 2

Related Questions