Link to home
Start Free TrialLog in
Avatar of MarkIsrael
MarkIsraelFlag for United States of America

asked on

Windows 7 Logon Script Does Not Reconnect Network Drives on Logon

My Logon.vbs script is not mapping drives for Windows 7 clients. It has worked for years and now that we are moving into Windows 7 Enterprise this is a nightmare.

I see an awful lot of people having the same issue, but I don't see any straight up fixes from  Microsoft. I am about ready to pay the ridiculousas fee for MS Tech Support just too find out if there is a fix/Bug/or my favoritete "This is by Design".

The script is pretty simple and it came from the 'Microsoft Scripting Guys'. I use a GPO to point to the script.  Anyone have an idea on how to fix this nasty bugger.

Thanks,
logonscr.vbs
Avatar of RobSampson
RobSampson
Flag of Australia image

I think you're main problem is this:
'=======================================================
' MappedDrive function
'=======================================================
Function MappedDrive (DriveLetter, SharedPath)

On Error Resume Next
If objNetwork.DriveExists(DriveLetter) Then
   objNetwork.RemoveNetworkDrive DriveLetter, True, True
End If
On Error Resume Next
If objNetwork.DriveExists(SharedPath) Then
   objNetwork.MapNetworkDrive DriveLetter, SharedPath
End If
End Function

Open in new window


which I would change to this:
'=======================================================
' MappedDrive function
'=======================================================
Function MappedDrive (DriveLetter, SharedPath)

On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.DriveExists(DriveLetter) Then
   objNetwork.RemoveNetworkDrive DriveLetter, True, True
End If
On Error Resume Next
If objFSO.FolderExists(SharedPath) Then
   objNetwork.MapNetworkDrive DriveLetter, SharedPath
End If
End Function

Open in new window


The main problem is that the DriveExists and FolderExists methods are part of the Scripting.FileSystemObject object, and not the WScript.Network object.

Regards,

Rob.
Avatar of MarkIsrael

ASKER

If this works your a Scriptig Guru that mere words cannot explain. I am giving this a try and see what happens.
For reasons unkown the new Map routine did not work. I am not sure if the objFSO is being picked up.
OK, instead of having
On Error Resume Next

can you put
Err.Clear
On Error GoTo 0

and run it manually to see what happens?

Thanks,

Rob.
ASKER CERTIFIED SOLUTION
Avatar of MarkIsrael
MarkIsrael
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey give me my 500 points for finding a fix to this vexing issue.
Hi, thanks for the info.  According to this though:
http://support.microsoft.com/kb/937624

it looks like it would only affect members of the administrators group while UAC is enabled.  Is that the case with you?

Rob.
It took a lot of hard work to come up with an easy, simple and fast solution that works everytime.
In our envrionment our users have Admin Rights to the local machine. Also, by default the Windows 7 UAC is on. I tried getting rid of the UAC and still it wouldn't work. I knew there wasn't a way for me to remove some 250 users from the local admin so I was stuck. The registry fix works great and has continued to work.