troubleshooting Question

attached network drives after server failure

Avatar of davidummel
davidummelFlag for United States of America asked on
StorageWindows Server 2003Project Management
2 Comments1 Solution294 ViewsLast Modified:
Hello,
we have experienced a server failure that was our NAS. i have restored from backup to anouther server all the network shares and created a new login script to reflect the new location of these shares. with the code shown below i had hoped that all the existing network shares on individual computers would be removed and repopulated with what i specify in the script. what is happening is that the original shares that point to a server that no longer exists remain. it isnt until the user right click, and selects disconnect for each of these shares then logs off then back in that they populate. please read the below script to see what i am doing wrong. what i wish it to do is remove all shares, then repopulate because i will have to go thru this whole excersize again because the location of the shares now is temoprary until i recieve a new server.
 here is the script;

'**********************************************************************************
' Set Environment Variables UMMEL 5/19/08
'*********************************************************************************
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set WSHShell = WScript.CreateObject("WScript.Shell")

On Error Resume Next

Domain = WSHNetwork.UserDomain
UserName = "" 

While UserName = "" 
UserName = WSHNetwork.UserName
MyGroups = GetGroups(Domain, UserName)
Wend

'*********************************************************************************
' Main Process:
'*********************************************************************************
GrpMeb UserName
ShowBox

Wscript.Quit

'*********************************************************************************
'Function: GetGroups
'*********************************************************************************
Function GetGroups(Domain, UserName)
Set objUser = GetObject("WinNT://" & Domain & "/" & UserName)
GetGroups=""
For Each objGroup In objUser.Groups
GetGroups=GetGroups & "[" & UCase(objGroup.Name) & "]"
Next
End Function

'********************************************************************************
'Function: InGroup
'********************************************************************************
Function InGroup(strGroup)
InGroup=False
If InStr(MyGroups,"[" & UCase(strGroup) & "]") Then
InGroup=True
End If
End Function

'*********************************************************************************
' MapDrives Subroutine
'*********************************************************************************
Sub MapDrive(sDrive,sShare)
On Error Resume Next
WSHNetwork.RemoveNetworkDrive sDrive
Err.Clear
WSHNetwork.MapNetworkDrive sDrive,sShare
End Sub
'********************************************************************************
'Disconnect ALL mapped drives
'********************************************************************************
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
    WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
'********************************************************************************
'Give the PC time to do the disconnect, wait 300 milliseconds
'********************************************************************************
wscript.sleep 300
'********************************************************************************
'Map Drives:
'********************************************************************************
Sub GrpMeb(UNAME)
MapDrive "p:", "\\virus\encina photos"
MapDrive "h:", "\\virus\emergency_response"
MapDrive "g:", "\\virus\common"
MapDrive "m:", "\\virus\maintenance"
End Sub
'
'********************************************************************************
'Display Dialog:
'********************************************************************************
Sub ShowBox
strMsgtxt = "You are mapped to the following drive letters:" & vbNewLine
strMsgtxt = strMsgtxt & "p: = \\virus\encina photos" & vbNewLine
strMsgtxt = strMsgtxt & "h: = \\virus\emergency_response" & vbNewLine
strMsgtxt = strMsgtxt & "g: = \\virus\common" & vbNewLine
strMsgtxt = strMsgtxt & "m: = \\virus\maintenance" & vbNewLine
strMsgtxt = strMsgtxt & "You are mapped to the following printers:" & vbNewLine
msgbox = WshShell.Popup(strMsgtxt, 2, "Logon Script", 0)
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros