I had a working script for Windows XP clients, distributed via group policy from Windows Server 2003 PDC.
This is the main part of the script:
Function ggMapNetworkDrive(fDriveLetter, fShareName, fDrives, fWSHNet) 'Map a network drive Dim lExist lExist = -1 For i = 0 to fDrives.Count - 1 Step 2 If fDrives.Item(i) = fDriveLetter Then lExist = i End If Next If lExist = -1 Then 'no drive, map us a drive fWSHNet.MapNetworkDrive fDriveLetter, fShareName Else If fDrives.Item(lExist+1) = fShareName Then 'do nothing, mapped to right point Else 'is mapped somewhere else; remove then map then add again fWSHNet.RemoveNetworkDrive fDriveLetter, False, True fWSHNet.MapNetworkDrive fDriveLetter, fShareName End If End If End Function
How to do the above in Windows 7?
EDIT: Error message...
Script: \\full-path-to-script\logon.vbs Line: (line containing 'fWSHNet.MapNetworkDrive fDriveLetter, fShareName') Char: 2 Error: The network path was not found Code: 80070035 Source: WSHNetwork.MapNetworkDrive
After further inspection I can see something is wrong with networking, here are the symptoms: pinging and address resolution works, access to all computers on the same segment works as expected, but only access to PDC (windows 2003) is not working as expected (as experienced from win XP clients).
I made a change for MapNetworkDrive to map to FQDN and it allowed the script to run. Still access to \server without the domain is not restored yet.