Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I know there's a lot of talk about scripts mapping network drives, but I haven't seen much about this specific problem. We have our users' home folders defined in Active Directory user objects, under the Profile tab. It is set to map it to drive H. This works fine if the computer stays on our network, but, as is common with many of our laptop users, they will restart at some point while off our network, and the home folder will disappear. That's fine, but the problem is when they return to our network with their laptop sleeping, the home folder does not reappear until they log off or restart.

Essentially, the home folder needs that "reconnect" option that normal mapped drives have. My fix has always been to map it inside of our script that removes and remaps our other drives. It works, but is probably attemping to map that H drive twice. Is there any better way to get a Home folder to stick, or is this about the best I can do?

Also, for the other drives, it seems kind of messy to remove and remap every time, but I'm guessing this is a common practice, because without removing them, we wouldn't have as much control over mapped drives, and making changes would be difficult. (because the old drives would stick)

Set WshNetwork = CreateObject ("WScript.Network")

'************************************************
'DELETE ALL NETWORK DRIVES
'************************************************
Set Drives = WshNetwork.EnumNetworkDrives

For i = 0 to Drives.Count - 1 Step 2
    On Error Resume Next
    wshNetwork.RemoveNetworkDrive Drives.Item(i), True, True
Next

'************************************************
'MAP THESE DRIVES
'************************************************
On Error Resume Next
WshNetwork.MapNetworkDrive "h:", GetObject("LDAP://" & CreateObject    ("ADSystemInfo").Username).homeDirectory, True
On Error Resume Next
WshNetwork.MapNetworkDrive "p:", "\\server\map1", True
On Error Resume Next
WshNetwork.MapNetworkDrive "s:", "\\server\map2", True

P.S. Does the On Error Resume Next actually need repeated like that? That is how my predecessor wrote it. Wouldn't once at the beginning cover it all?

share|improve this question
3  
On Error Resume next is in effect for the entire script. Normally you would set that at the top of the script when declaring your variables or script settings. So you do not need it that many times in a script. –  Mike Jul 13 '12 at 17:28
    
This is a great question, have you found an answer? Dealing with XP clients not connecting their AD home folder after sleep mode. Can't find a solution other than mapping it as well in a login script (hundreds of scripts to update and not really an option). Hope someone has the answer! –  user135991 Sep 14 '12 at 16:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.