Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Slow Network Places in XP - A Fix! 1

Status
Not open for further replies.
Feb 4, 2002
792
GB
I spent many months trying to find a solution to this, and determined that this can be improved (slightly), but that much faster are normal shortcuts to the same places as the "folder shortcuts" in Network Places.

Now, Folder SHortcuts can be created by creating a desktop.ini file and a shortcut link file, and making them system files in that folder. If you go to command-prompt, and then navigate to the hidden folder NetHood in your user profile on your machine, then cd to one of your network places folders, then "dir" you will see only these two files. You can copy these, and change the shortcut target... but for some reason this doesn't work, even though it is listed in Windows XP Annoyances, by David Karp, published by O'Reilly.

However, thanks to playing around I discovered that although you can't create a shortcut manually in My Network Places (one of the annoyances I had, and came across for others), you CAN create a shortcut in the hidden NetHood folder directly. (Not sure how they do this, nor why, but you can do this)

So, anyway, I created a script that creates shortcuts in your My Network Places, and the link follows:

If you test this alongside a normal Network Places folder, you will see a marked improvement in speed!!
The only downside is that in Windows explorer, because these shortcuts are files, they don't list in My Network Places on the left-hand folder nav pane in explorer. This is only a minor problem though, because you can click directly on My Network Places on the left, and then double-click the shortcut on the right! This opens the folder from the network one the left, and you can navigate the folders within the shortcut location as normal.

Next, a small reghack. The reason is that Windows XP, by default, create s a new network place after you visit network places in explorer. It seems to do this sometimes, but not all, and all this does is clog up My Network Places with unwanted folder-shortcuts!
The following link is to a registry hack that will add two new keys that will stop this from happeneing. To change back, simply change the values to 0 instead of 1 in the reg file and double-click again.


Please use these files and pass on as necessary. My site is a bit under-worked, but will soon (when I get time) be up and running with nice links to these scripts etc.

HTH,

Will
[morning]

Disclaimer: I accept absolutely no responsibility for any adverse affects the files listed above may have on your computer. By downloading and using, you do so at your own risk.
 
To create shortcuts in My Network Places, open it an click 'Add network place.' This starts the shortcut wizard.

To stop shares that are browsed from automaticly being added to My Network Place:

. Run Gpedit.msc using "Start Button" -> "Run..."
. In the Console Window go to this folder "User Configuration" -> "Administrative Templates" -> "Start Menu and Taskbar"
. Go to the entry "Do not add shares of recently used documents to Network Places" and double click it and set to "Enabled"
. It is the same as setting this DWORD registry key :

[HKEY_CURRENT_USER \Software \Microsoft \Windows \CurrentVersion \Policies \Explorer]
NoRecentDocsNetHood = 1 (Default = 0)

Finally, to stop the Auto addition from scanning of available shares and printers:

. Open Control Panel
. Double click Folder Options (Inside the grouping Appearance and Themes)
. Select the View tab
In the Advanced Settings list untick Automatically search for network folders and printers

. It is reflected with this DWORD value in the registry:
[HKEY_CURRENT_USER \Software \Microsoft \Windows \CurrentVersion \Explorer \Advanced]
NoNetCrawling = 1

To "speedup" browsing of shares in My Network Places, stop XP from first scanning for scheduled tasks:

1. Open up regedit.
2. Navigate to HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/Current Version/Explorer/RemoteComputer/NameSpace.
3. Find a key named {D6277990-4C6A-11CF-8D87-00AA0060F5BF}.
4. Right click on it and delete it.


 
Good tips bcastner, but I have tried all of those (been there, done that), and still the shortcuts added to NetHood are much more quick than the normal Network Places.

I spent 6 months in communique with Microsoft about this problem, and collected many "workarounds", including the tweaks above mentioned by you. They could not "fix" it. We scanned through 18Mb - 100Mb Port scanning logs from NetMon2 from Microsoft, and still could not figure why it was so slow accessing the network through My Network Places in XP. This took a lot of time!

In the end MS said, essentially, "we're sorry, but there is no fix for this problem, it is just the way My Network Places works. We suggest a workaround that you use Mapped Drives." Fine, if that was acceptable. [smile] But my boss and his bosses will not accept that as a solution because everyone at the company has used My Network Places since Windows 2000, and do not want to change (why are bosses so difficult! [smile])

I have also been on many more forums than this one, and many people have also used the above "fixes" to no great effect. Hence why I post the script.

Changing the scheduled tasks scanning DOES NOT WORK in our situation, and was a fix for pre-Windows XP. I have also found evidence that it does not do any good in other people's experience.

This script, and using normal Shortcuts instead of folder-shortcuts, increases speed noticeably.

Unticking Automatically Search for net folders and printers does increase speed a little, but there were still times it took as long as 10 minutes to show a single file in a folder on the network when browsing Open dialog in Word, hanging Word all this time. Using my shortcuts for the last 3 months, no one has experienced the same problems they had before.

I am posting my script here from direct experience, and it works a treat.

The Reg hack I got from one of the web sites that already lists the "fixes" bcastner has presented.

I do recommend that people try bcastners fixes above first, as they are fairly quick to implement, and you can carry on using My Network Places Folder-Shortcuts. But if you still feel it is slow (sometimes, not always), then try replacing your folder-shortcuts with normal shortcuts through my script.

Will
[morning]
 
. My Network Places is an enumeration of the NetHood folder, nothing else. There is absolutely no difference between your shortcut (which calls the XP API for shortcuts) and the GUI method. The end result shortcut is identical. There is no magic.

. I do not claim to speak for everyone's experience in the effects of eliminating the search for scheduled tasks on share browsing speed. I do know it is not true to claim this is "pre-XP"; the registry entry makes it clear that this is alive and well in the default XP install. I do know that I have not seen a web site by an MS-MVP in either Windows Shell or Windows Networking that does not recommend this registry change. I do know in my personal experience it makes a noticable difference.

. "Unticking Automatically Search for net folders and printers does increase speed a little, but there were still times it took as long as 10 minutes to show a single file in a folder on the network when browsing Open dialog in Word, hanging Word all this time. Using my shortcuts for the last 3 months, no one has experienced the same problems they had before."

Network slowness in Common Dialogue boxes is a different issue than My Network Places. There are multiple issues involved with this, summarized by Microsoft in two KB's:

The true fix for this is to update all Win2k servers to SP4, and all XP clients to SP2. This resolves opportunistic locking, SMB Signing, extended attribute, and column handler issues. In addition, the redirector under SP2 is substantially faster than in previous XP releases.

. "The Reg hack I got from one of the web sites that already lists the "fixes" bcastner has presented." My fixes use the XP GUI for folder options and Group Policy. This is preferred to a registry hack.
 
Hi bcastner,

I agree with the "pre-XP" comment. I was simply remembering off the top of my head one such web site that suggested this fix along with text similar to: "This was originally a problem on WIndows X(Either 98 or 2000), but it may still exist in XP. Doesn't hurt to try it." I also agree that it does seem to make a noticeable difference, just not a huge difference. remember I am talking about 10 minute waits, not just in Open dialogs, but also in Windows explorer. It just happens more often in Open dialogs.

As far as the SMB Links, and the slowness in Common Dialogue Boxes, these too are things we attempted to fix, but to no avail.

All our Windows 2000 machines are SP4 and have been since this came out, and our XP machines are XPSP2, though fairly recently. Still the problem exists, except using shortcuts. Originally I encouraged people to create shortcuts themselves on their desktops, but my boss soon told me not to do this, and to write a script to replace the Network Place Shortcuts. I certainly don't relish going to 100 PCs and getting people to log in for me, and then creating the 20 or so shortcuts by using Add Network Place. That's what scripts are for. I have another script that creates our standard shortcuts on all machines on the network, but at the moment this doesn't work through XPSP2, where I am defering to some document lniks provided by your good self. However, much of our network locations are hard coded into the script so that there is little user intervention needed, unlike this single script which is so that people can email me network places they want to add to NetHood, and I can run the script from my machine and create the shortcut for them. Again, avoiding going to their machine and Adding a Network Place.

Now... Unfortunately you are completely wrong about the shortcuts in NetHood. I have done extensive research into this. My Network Places use Folder-Shortcuts, which are completely different to normal shortcuts. So they are not the same as you suggest.
I do agree that they are not magic though!

I have a book in fornt of me as I type by David A. Kemp which outlines the differences between Folder-Shortcuts and normal shortcuts, which is what my script creates.
"Windows XP Annoyances" ISBN:0-596-00416-8

In short, a folder shortcut contains a "target.lnk" file, and a Desktop.ini file. These are hidden. The result is that when you enter this folder from explorer, you are taken to the network area which is specified by target.lnk

The Desktop.ini file contains similar to the following:
[.ShellClassInfo]
CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}
Flags=2
ConfirmFileOp=0

This folder is NOT a shortcut like my script which "calls the XP API" to create.

Unfortunately as well, the Book contains a sample script that creates such folders with these files, but the resulting folder does not work as it should. When you double-click on it, all you see are the two files Desktop.ini and target.lnk

If you would like proof of this, I suggest you do as I originally posted and go to a command prompt and then from explorer-ing My Network Places, drag the folder to a cd prompt (quickest this way), then open one of the "links" and type dir. You will see only two hidden system files.

As far as the GPO edit, nice one! I shall use that instead of the registry hack. Unfortunately I found that hack before I found bcastner!

Will
[morning]
 
I created a script a long time ago that creates folder shortcuts properly, however, I have decided after fighting the additional latency associated with having them, that I just won't allow them in my environment. If anyone needs access to the script to create them and actually have them work..let me know.
 
I just cannot duplicate your results. If you use the 'Add Network Place' access to the shortcut wizard you create a direct shortcut to the share.

This is in opposition to the autodiscovered folder shortcuts. You can visually tell the difference in the two types by seeing if there is a little network cable appearing under the folder icon. If yes, and this is what is created by the Add Network Place shortcut wizard, there is no desktop.ini and there is no overhead.

It is a direct call to WinExecute, identical to using the Explorer address bar or Start, Run. The target is \\share_server\sharename






 
My fault, sorry. You can't see the desktop.ini unless you get rid of its attributes. when you are in dos prompt you should use attrib instead of dir to see it. Here are some screen shots:
This first one shows what you explained, that you right-click the folder in explorer to look at where it is pointing... However, unlike a normal shortcut, you can't edit the target. This is because the folder doesn't contain the ACTUAL link, the target.lnk file does.
folder-shortcut-explorer-view.jpg


This second one shows when you "attrib" (again, sorry!) in the folder through dos.
folder-shortcut-dos-view.jpg


Just to follow up, reading some of my posts here, it may look like I'm trying to "one-up" bcastner, but I just want to say I'm not. His (or her, same goes for the rest of this post...) posts here have been invaluable, and IMO he knows his stuff!

Will
[morning]
 
MisterNiceGuy,

I'd be interested in seeing your script. I wrote one which didn't work, and then I compared to and amended so it looked exactly like the one on the XP Annoyances Book, and still it did not work!
I even emailed the author at his web site stating so, and he never replied...

Anyway, the latency is exactly why I created this other very simple script, probably complicated though by my lack of experience, to make the snormal shortcuts... the latency disappears! They are VERY fast! The downside is they are not folders...

Will
(will at my website above is my email)
 
BCaster, On Windows XP, I just used the Add Network Place wizard, and it did create a folder, exactly like the ones it autocreates. They all create the latency we are referring to. The easiest way to tell if a shortcut is a Network shortcut...one with a folder etc. as compared to a regular old shortcut is to use the UP Folder arrow after going to the location if it takes you back to My Network places, then it is Network shortcut which has a folder and the appropriate Desktop.ini and LNK file. Here is the function I developed to create the true My Network place shortcuts.

The first function creates the Network Link and relies on the second function which only creates the shortcut.

=============================================

Dim fs,Shell
Set Shell = WScript.CreateObject("WScript.Shell")
Set fs = Createobject("Scripting.FilesystemObject")


CreateNetworkLink "My Test Link","\\myserver\myshare\myfolder","My Link to test"

Sub CreateNetworkLink(LinkName,LinkTargetPath,LinkDescription)
'> Get the path to the Network Neighborhood special folder.
Set NetHoodfolder = fs.getfolder(Shell.SpecialFolders("NetHood"))
Folder=NetHoodFolder &"\" &LinkName
If Fs.FolderExists(Folder)=False Then
Fs.CreateFolder(Folder)
set LinkFolder=fs.getfolder(Folder)
Linkfolder.attributes=1
End If
CreateLink Folder,"target.lnk",LinkTargetPath,LinkDescription,"",""
WriteFile Folder &"\Desktop.ini","[.ShellClassInfo]",2
WriteFile Folder &"\Desktop.ini","CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}",8
WriteFile Folder &"\Desktop.ini","Flags=2",8
WriteFile Folder &"\Desktop.ini","ConfirmFileOp=0",8
End Sub

'>This Subroutine Creates the Shortcut Based on the parameters sent to it.
Sub CreateLink(LinkLocation,LinkName,LinkTargetPath,LinkDescription,LinkWorkingDirectory,LinkIconLocation)
Set ShellLink = Shell.CreateShortcut(LinkLocation &"\" & LinkName)
ShellLink.TargetPath = LinkTargetPath
ShellLink.WindowStyle = 1
ShellLink.Description = LinkDescription
ShellLink.WorkingDirectory = LinkWorkingDirectory
shelllink.IconLocation = LinkIconLocation
ShellLink.Save
End Sub

 
then it is Network shortcut which has a folder and the appropriate Desktop.ini and LNK file. Here is the function I developed to create the true My Network place shortcuts."

The shortcuts I create using 'Add Network Place' do not contain a desktop.ini, and the folder icon has a network cable symbol under the folder itself.

The autocreated folders have a desktop.ini, and no network cable symbole under the folder itself.
 
For the record...

Both the Autocreated My Network Places shortcuts and those created using the wizard have a folder, a lnk file, and a desktop.ini file. At least that is the case on the over 7000 or so computers I work with. Your computer might be acting differently because..well...it's your computer and you're special.

Sincerely

MisterNiceGuy
 
Explorer shows autocreated links as type File Folder, and are as you describe. Wizard created links are type Folder, not File Folder, and contain nothing but the UNC path.
 
I just re-verified this on my XP SP2 system. Go look at your Nethood folder under a command prompt once you are in it run attrib and you will see the desktop.ini file. If it doesn't have one, then refer to my post above and have a nice day. I'm finished with this thread.
 
I can use WshShortCut in a login script but the shortcut it creates is only a shortcut while a network share created with the Add Network Place wizard, creates what appears to be a dynamic folder shortcut.

In Explorer, when you double-click on the shortcut made by WshShortCut and then proceed to click the up-folder icon it traverses through the entire network structure. When you double-click the wizard folder shortcut and then proceed to click the up-folder icon it traverses up to My Network Places and then My Computer skipping all the network stucture.

Should you need examples to understand what I mean, create a Folder Shortcut to a network share by using the Add Network Place wizard in My Network Places. Then right-mouse on any network share and create shortcut, move shortcut off desktop and into %userprofile%nethood folder for comparison.

The Wizard shortcut is a shell folder shortcut, and does not contain a desktop.ini file.
 
The Wizard shortcut is a shell folder shortcut, and does not contain a desktop.ini file."

bcastner,

I can't understand why you cannot view a desktop.ini file. Please trust what I say: the 7000 odd computers administrated by MNG, and the 100 I administer, and the 1000's that are administered by peopel I have been in contact with since I started trying to find a solution to the latency problem that did not include mapped drives, all have desktop.ini files in the folders. You can ONLY view this file through the command prompt and not windows explorer. You can not see the file using dir unless you first strip it's attributes using attrib. However, leaving the file alone, you can see it in the Command Prompt if you run attrib without any arguments on that folder.

Now, if you use the Add Network Place wizard and select a shared folder on the server, you will get a little folder with a network graphic underneath it. If you use the wizard to select a folder that is not shared, but is on the network (i.e. under a share), you will get a folder without the network icon. BOTH are exactly the same as far as functionality is concerend (Folder-Shortcuts as MNG's script above creates, supposedly - see my message below), but simply use a different icon for the picture.

You mention that with a shortcut, if you click up the hierarchy you see the whole entire network. Yes, this is one of the downsides of using the normal shortcuts... however, the latency seems to be linked to the folder-shortucts rather than to anything else, including all the other "fixes" you outlined previously and I and others have tried.

Apart from seeing the "whole" network, you do see the folder structure within the link, and so this is not that bad a problem, and this problem is outweighed by the increas in speed a normal shortcut delivers.

To MisterNiceGuy (MNG):
You script needs also a sub routine for WriteFile before it works. The following is something I scared up and seems to work.
Also, I have now tested it and it works! The only difference between yours and my original script is that I wrote the text into a string and added it to the file in one go rather than a Write and 3 Appends as you did. Oh! and I set the attributes to 6 for the folder, rather than 1.

hmmm... just tried changing the attributes, but still no joy...

Here's my code if you can suggest why its failing, I would be interested from a learning stand-point:
Code:
TargetName = CommandLine(1)

If TargetName = "" Then
	TargetName = InputBox("Type the name of the folder to link:", _
		"Create Folder Shortcut sScript - CreateFldrSCut.vbs")
End If

If FolderExists(TargetName) = False Then
	MsgBox "TargetName does not appear to be a valid folder." & Chr(13) & Chr(10) & _
	"Please check your network connection, spelling," & Chr(13) & Chr(10) & _
	"and whether folder exists."
	WScript.Quit
End If

If Right(TargetName, 1) = "\" Then TargetName = Left(TargetName, Len(TargetName)-1)

DesktopFolder = GetSpecialFolder("Desktop")

If Right(DesktopFolder, 1) <> "\" Then DesktopFolder = DesktopFolder & "\"

X = 0
Do
	Y = X
	X = InStr(X + 1, TargetName, "\")
Loop Until X = 0

NewTargetName = DesktopFolder & "Folder shortcut to " & Mid(TargetName, Y + 1)

FolderCreate(NewTargetName)

Call Shortcut(NewTargetName & "\target.lnk", TargetName)

Text = 	"[.ShellClassInfo]" & Chr(13) & Chr(10) & _
		"CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}" & Chr(13) & Chr(10) & _
		"Flags=2" & Chr(13) & Chr(10) & _
		"ConfirmFileOp=0" & Chr(13) & Chr(10)

Call WriteToFile(NewTargetName & "\desktop.ini", Text)
Call SetAttributes(NewTargetName & "\desktop.ini", 1)

Here are a few library functions and subs I created/copied while scripting that I have used in the above script:
Code:
'Functions for common tasks
'**************************

Function CommandLine(Number)
	Set Arguments = WScript.Arguments
	If Number <= Arguments.Count Then
		CommandLine = Arguments(Number - 1)
	Else
		CommandLine = ""
	End If
End Function

Function FolderExists(FolderName)
	Set oFSO = CreateObject("Scripting.FileSystemObject")
	FolderExists = oFSO.FolderExists(FolderName)
End Function

Function FolderCreate(CreateFolderName)
	Set oFSO = CreateObject("Scripting.FileSystemObject")
	Set Result = oFSO.CreateFolder(CreateFolderName)
	If Result.Path = "" Then
		FolderCreate = False
	Else
		FolderCreate = True
	End If
End Function

Function GetSpecialFolder(SpecialFolderName)
	Set WSHShell = WScript.CreateObject("WScript.Shell")
	GetSpecialFolder = WSHShell.SpecialFolders(SpecialFolderName)
End Function

'Sub Routines for common tasks
'*****************************

'Create a shortcut
Sub Shortcut(LinkFile, CommandLine)
	Set WSHShell = WScript.CreateObject("WScript.Shell")
	If LCase(Right(LinkFile, 4)) <> ".lnk" And _
		LCase(Right(LinkFile, 4)) <> ".url" Then _
		LinkFile = LinkFile & ".lnk"
	Set ShortcutHandle = WSHShell.CreateShortcut(LinkFile)
	ShortcutHandle.TargetPath = CommandLine
	ShortcutHandle.Save
End Sub

'Read from a file
Sub ReadFromFile(FileName)
	Const ForReading = 1, ForWriting = 2, ForAppending = 8
	Set oFSO = CreateObject("Scripting.FileSystemObject")
	Set oFile = oFSO.OpenTextFile(FileName, ForReading)
	Buffer = ""
	Do Until oFile.AtEndOfStream
		Buffer = Buffer & oFile.ReadLine & vbCrLf
	Loop
	oFile.Close
	ReadFromFile = Buffer
End Sub

'Write text to a file
Sub WriteToFile(FileName, Text)
	Const ForReading = 1, ForWriting = 2, ForAppending = 8
	Set oFSO = CreateObject("Scripting.FileSystemObject")
	If oFSO.FileExists(FileName) Then
		Set oFile = oFSO.OpenTextFile(FileName, ForAppending)
		oFile.Write vbCrLf
	Else
		Set oFile = oFSO.CreateTextFile(FileName)
	End If
	oFile.Write Text
	oFile.Close
End Sub

'Set Attributes of a file
Sub SetAttributes(FileName, Attrib)
	Set oFSO = CreateObject("Scripting.FileSystemObject")
	Set oFile = oFSO.GetFile(FileName)
	oFile.Attributes = Attrib
End Sub

Anyway, probably best to knock this thread on the head as it isn't going to go anywhere new. MNG please email me your thoughts.

Will
[morning]
 
Forgot to include the WriteFile sub:

Code:
Sub WriteFile(FileName, Text, RWA)
	' ForReading, RWA = 1;
	' ForWriting, RWA = 2;
	' ForAppending, RWA = 8
	Set oFSO = CreateObject("Scripting.FileSystemObject")
	If oFSO.FileExists(FileName) Then
		Set oFile = oFSO.OpenTextFile(FileName, RWA)
		oFile.Write vbCrLf
	Else
		Set oFile = oFSO.CreateTextFile(FileName)
	End If
	oFile.Write Text
	oFile.Close
End Sub
 
I know I said I was done with this post, but this was the easiest response method for me. I took a quick look and identified why your script isn't working. I did a tiny modification and your script works fine now. In a nut shell.. you have to set the attributes on the folder itself.

Here is your create folder function.

Function FolderCreate(CreateFolderName)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set Result = oFSO.CreateFolder(CreateFolderName)
If Result.Path = "" Then
FolderCreate = False
Else
FolderCreate = True
End If
End Function


Here is how my script creates the folder...

Sub CreateNetworkLink(LinkName,LinkTargetPath,LinkDescription)
'> Get the path to the Network Neighborhood special folder.
Set NetHoodfolder = fs.getfolder(Shell.SpecialFolders("NetHood"))
Folder=NetHoodFolder &"\" &LinkName
If Fs.FolderExists(Folder)=False Then
Fs.CreateFolder(Folder)
set LinkFolder=fs.getfolder(Folder)
Linkfolder.attributes=1
End If
CreateLink Folder,"target.lnk",LinkTargetPath,LinkDescription,"",""
WriteFile Folder &"\Desktop.ini","[.ShellClassInfo]",2
WriteFile Folder &"\Desktop.ini","CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}",8
WriteFile Folder &"\Desktop.ini","Flags=2",8
WriteFile Folder &"\Desktop.ini","ConfirmFileOp=0",8
End Sub



Here is what your create folder function needs to look like specific to these special folders...

Function FolderCreate(CreateFolderName)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set Result = oFSO.CreateFolder(CreateFolderName)
If Result.Path = "" Then
FolderCreate = False
Else
Result.attributes=1
FolderCreate = True
End If
End Function
 
Thanks MNG! Good to know there are some knowledgeable people out there! :)

I have to admit when I added the attribute part of the script, copying directly from the book, I looked up this particular method and could not get a clear picture of how it worked. I tried a couple of different ways to set the attributes, but needed your fine abilities to get it right! :)

Anyway, it was more for information as even though now I can do this thanks to your help, it's a moot point because of the aforementioned overhead of these network folder shortcuts.

Take care, and hope you're around again for any scripting Q's I might have! :)

Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top