gtownladytn
asked on
Script to remap drives at logon
I need a login script that will remap drives from old server name to DFS name. I tested the script and it worked on windows 7. Now a week later, it is not running successfully. This script is referenced in the User Profile in AD. Our environment is 2012 AD, 2008 and windows 7 / 10 OS.
strOldServer = "\\oldfileserver\"
strNewServer = "\\x.x.x\DFSshare\"
Set objNetwork = CreateObject("WScript.Netw ork")
Set objDrives = objNetwork.EnumNetworkDriv es
For i = 0 To objDrives.Count - 1 Step 2
strDrive = objDrives(i)
strPath = objDrives(i + 1)
If Left(LCase(strPath), Len(strOldServer)) = strOldServer Then
strNewPath = Replace(strPath, strOldServer, strNewServer, vbTextCompare)
'WScript.Echo "Disconnecting " & strDrive & " from " & strPath & " and mapping it to " & strNewPath
On Error Resume Next
objNetwork.RemoveNetworkDr ive strDrive, True, True
WScript.Sleep 3000
Err.Clear
On Error GoTo 0
objNetwork.MapNetworkDrive strDrive, strNewPath, True
End If
Next
strOldServer = "\\oldfileserver\"
strNewServer = "\\x.x.x\DFSshare\"
Set objNetwork = CreateObject("WScript.Netw
Set objDrives = objNetwork.EnumNetworkDriv
For i = 0 To objDrives.Count - 1 Step 2
strDrive = objDrives(i)
strPath = objDrives(i + 1)
If Left(LCase(strPath), Len(strOldServer)) = strOldServer Then
strNewPath = Replace(strPath, strOldServer, strNewServer, vbTextCompare)
'WScript.Echo "Disconnecting " & strDrive & " from " & strPath & " and mapping it to " & strNewPath
On Error Resume Next
objNetwork.RemoveNetworkDr
WScript.Sleep 3000
Err.Clear
On Error GoTo 0
objNetwork.MapNetworkDrive
End If
Next
ASKER
we have 12 different logon scripts with various folder mappings.
I have used the net use to remove the mapping and then create a persistent mapping.
This script was working but I think the old mapping must still be working in order for the new mapping to occur. I had disabled the sharing of the old file server. I put the shares back and now it is working. I created the shares as read only so users will not login on Monday and started editing data on the old server.
I have used the net use to remove the mapping and then create a persistent mapping.
This script was working but I think the old mapping must still be working in order for the new mapping to occur. I had disabled the sharing of the old file server. I put the shares back and now it is working. I created the shares as read only so users will not login on Monday and started editing data on the old server.
what is the relationship between the old data on the old server and the new data on the new server?
If the two systems are 2003 R2 or newer,
I would combine the old server as the reference into a DFS replication group this way the data will be synchronized no matter which system the user accessed
then go through the process of unmapping the drives in the login scripts.
It is unclear whether you are dealing with mapped drives by login scripts and/or through user mappings
if these are folder redirections, the process is to revoke the prior while creating a new GPO with the new path.
If the two systems are 2003 R2 or newer,
I would combine the old server as the reference into a DFS replication group this way the data will be synchronized no matter which system the user accessed
then go through the process of unmapping the drives in the login scripts.
It is unclear whether you are dealing with mapped drives by login scripts and/or through user mappings
if these are folder redirections, the process is to revoke the prior while creating a new GPO with the new path.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
one is to get the list of the shares/mappings
then you need to delete the existing mapping and create the new one.
what was mapping the drives originally?