Link to home
Start Free TrialLog in
Avatar of TexasEx95
TexasEx95

asked on

I'm having trouble with a vbscript that maps network drives

This is a three-part issue:

1. Out of nowhere, our network drive mapping disappeared on our desktops and laptops. What would cause that?

2. On at least a couple of my desktops, it won't even give me an option to map a network drive under My Computer. How can I give these users and/or computers mapping capability?

3. I receive a Microsoft VBScript compilation (800A0400) Expected statement error on a computer and user I recently added to the domain. There's a problem with the last line.  The code is listed below.
Const Drive_H     = "cn=fake1"
Const Drive_S     = "cn=fake2"
Const Drive_L     = "cn=fake3"
Const Drive_V     = "cn=fake4"
Const Drive_M     = "cn=fake5"
Const Drive_Y     = "cn=fake6"
 
Dim wshNetwork,strUserName
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
 
' msgbox (wshNetwork.UserName)
 
strGroups = LCase(Join(CurrentUser.MemberOf))
 
' msgbox (strGroups)
 
On Error Resume Next
 
If InStr(strGroups, Drive_Y) Then
    WshNetwork.RemoveNetworkDrive "y:", yes, yes 
    wshNetwork.MapNetworkDrive "y:", "\\server\sharedfolder$"
end if
 
If InStr(strGroups, Drive_H) Then
    WshNetwork.RemoveNetworkDrive "h:", yes, yes 
    wshNetwork.MapNetworkDrive "h:", "\\server\users\" & wshNetwork.UserName
end if
If InStr(strGroups, Drive_L) Then
    WshNetwork.RemoveNetworkDrive "l:", yes, yes 
    wshNetwork.MapNetworkDrive "l:", "\\server2\CC40"
end if
 If InStr(strGroups, Drive_M) Then
    WshNetwork.RemoveNetworkDrive "m:", yes, yes 
    wshNetwork.MapNetworkDrive "m:", "\\server\sharedfolder2$"
end if
If InStr(strGroups, Drive_S) Then
    WshNetwork.RemoveNetworkDrive "s:", yes, yes 
    wshNetwork.MapNetworkDrive "s:", "\\server\sharedfolder3$"
    
End If
If InStr(strGroups, Drive_V) Then
    WshNetwork.RemoveNetworkDrive "v:", yes, yes 
    wshNetwork.MapNetworkDrive "v:", "\\server\sharedfolder4$"
end if
 
Wscript.Quit
 
 
\\server\sysvol\ya.local\scripts\SBS_LOGIN_SCRIPT.bat

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia 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
SOLUTION
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
Avatar of TexasEx95
TexasEx95

ASKER

RobSampson,

I'm very much a newbie to vbscript. When you say remove "Map Network Drive" and "Disconnect Network Drive," would lines 22 and 23 then read the following as an example?

WshNetwork. "y:", yes, yes
wshNetwork. "y:", "\\server\sharedfolder$"

Thanks for your help,
TexasEx95
SOLUTION
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