I like the "My Network Places" functionality in Windows XP. The way I use Windows Explorer is to have mapped drives for high-use locations. "My Network Places" becomes a psuedo-"favourites" - linking to, for example, a folder where a third-party extract is dropped, or a shared folder from another department, or a folder used for backups but rarely accessed.
With that in mind I thought it would be handy to keep a copy of the UNC paths contained in "Network Places". There's a few tools that will allow you to print folder contents ("Network Places" is stored in the "NetHood" folder in your user profile) but that only resulted in the names, not the UNC paths.
Here's the VBScript I ended up cobbling together to save "My Network Places" to a text file, enumerating each item and getting the name as well as the UNC path. I hope this helps if, like me, you've ever considered just taking a screenshot of Windows Explorer to keep track of your network places:
Special Note: This works perfectly on my PC, however I can't take any responsibility for it working anywhere else. It's just a quick script that did the job for me, not a fully debugged application.
' ------------------------------------------------------------------------------
' Writes all folders/links in "My Network Places" on Windows XP to a text file
' Thomas Williams 13-May-2010
' adapted from http://www.tek-tips.com/viewthread.cfm?qid=1309939&page=9 and
' http://blogs.technet.com/heyscriptingguy/archive/2005/05/09/how-can-i-create-a-shortcut-in-my-network-places.aspx and
' http://msdn.microsoft.com/en-us/library/bb774004%28v=VS.85%29.aspx
' ------------------------------------------------------------------------------
Const NETHOOD = &H13&
Set objShell = CreateObject
("Shell.Application")
Set objFSO = CreateObject
("Scripting.FileSystemObject")
' file to write to (overwrite without prompting)
Set outputFile = objFSO.CreateTextFile
("C:\Network Places List.txt",
True)
' get the NetHood folder on Windows XP for the current logged in user
Set objFolder = objShell.Namespace
(NETHOOD
)
' loop through all items in NetHood folder
For Each objItem
in objFolder.Items
' if the item is a link e.g. not "Entire Network"
If objItem.IsLink
Then
' get the link/shortcut for the item
Set objLink = objItem.GetLink
' write to the output file, the display name of the folder, and the UNC path
outputFile.WriteLine
(objItem.Name & vbTab & objLink.Path
)
End If
Next
' close the output file
outputFile.
Close
The tricky part was dealing with the list of items returned by Shell.Namespace and finding out how to get the link properties from a FolderItem...luckily I'm on first-name speaking terms with my friend the MSDN Library :-)
Tags: windows, script
posted @ Thursday, May 13, 2010 12:52 PM