Avatar of davidummel
davidummelFlag for United States of America asked on

attached network drives after server failure

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
Project ManagementStorageWindows Server 2003

Avatar of undefined
Last Comment
davidummel

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
TheCapedPlodder

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
davidummel

thank you , this worked out for me!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck