Tuesday, September 07, 2010

Laptop Performance vs. Network Drive

Symptom: When working from home using a company laptop, ever notice that the corporate laptop appears to be much slower on your home network? Well, I have had this problem for a while. After a closer look, I found whenever I switch to Windows Explorer or trying to open a file, it will take almost a minute for it to showup.

Root Cause: In my case, I found out the root cause is actually a bunch of network drives that are causing this performance problem.
There are 4 network mapped drives on my laptop which access various resources on intranet. Some are setup by IT so that they will be mapped whenever you boot you computer on company intranet. However, at home, connection to intranet is slow or non-existent. Whenever you make Windows Explorer visible or showing a File dialog, Windows explorer will try to map all of them one by one. That is, the more network drives you have, the longer you have to wait until Windows decide to give up on reconnecting these network drives.

Solution: I end up created a VB script to batch start/stop the mapping. At home with limit access to internet, I will run the scripts to stop all the mapped drives. At work, I will run the script to start the mapping.

The vb script to stop network drive:
Set objNetwork = CreateObject("WScript.Network")
On Error Resume Next
objNetwork.RemoveNetworkDrive "X:", "True"
objNetwork.RemoveNetworkDrive "Y:", "True"
objNetwork.RemoveNetworkDrive "Z:", "True"

To start network drive:
Set objNetwork = CreateObject("WScript.Network")
On Error Resume Next
objNetwork.MapNetworkDrive "X:" , "[your URI]"
objNetwork.MapNetworkDrive "Y:" , "[your URI]"
objNetwork.MapNetworkDrive "Z:" , "[your URI]"

No comments: