This is a multi-part message in MIME format.
------=_NextPart_000_0175_01C5B47E.81ED78F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello everyone!
I need help with my script. The script runs fine under W2k3 Server. =
Everyone is set as a Domain User and Local Administrator and assigned to =
different groups under one OU. The script is written to map shares to =
drive letters and map printers. The script will run perfectly when a =
user is part of more than one group. Why is this happening? Here is =
the script (I have substituted <servername> for the actual name of the =
server):
Dim driveletter, drivepath, printerpath
Set FSO =3D WScript.CreateObject("Scripting.FileSystemObject")
Set WshNetwork =3D WScript.CreateObject("WScript.Network")
Set objShell =3D CreateObject("WScript.Shell")
sDomain =3D WshNetwork.UserDomain
strUser =3D UCase(WshNetwork.UserName)
strComputer =3D "."
'4/13/2005 changes: maps to common directories
CALL MAPDRIVE("Z:","\\<servername>\Public")
CALL MAPDRIVE("Y:","\\<servername>\Apps&Database")
'Maps printers changes: 5/16/2005 added all printer maps
CALL MAPPRINTER("\\<servername>\ADM_CENTRAL_01")
CALL MAPPRINTER("\\<servername>\SHARP AR-P450 PCL6")
CALL MAPPRINTER("\\<servername>\ADM_WEST_01")
CALL MAPPRINTER("\\<servername>\ADM_WEST_02")
CALL MAPPRINTER("\\<servername>\ADM_CENTRAL_01")
CALL MAPPRINTER("\\<servername>\DEV_CENTRAL_01")
CALL MAPPRINTER("\\<servername>\DEV_CENTRAL_01_UWCOLOR")
CALL MAPPRINTER("\\<servername>\DEV_CENTRAL_01")
CALL MAPPRINTER("\\<servername>\DEV_EAST_01")
CALL MAPPRINTER("\\<servername>\DEV_WEST_01")
CALL MAPPRINTER("\\<servername>\DEV_WEST_02_COLOR")
CALL MAPPRINTER("\\<servername>\ENG_CENTRAL_01")
CALL MAPPRINTER("\\<servername>\PROD_CENTRAL_01")
CALL MAPPRINTER("\\<servername>\PROD_WEST_02")
'6/30/2005 changes : This section is where drives are mapped based on =
group membership
'4/01/2005 changes : Determines distinguished name of user who has =
logged on.
'4/01/2005 changes : reports what groups user is in
On Error Resume Next
Set objSysInfo =3D CreateObject("ADSystemInfo")
'Wscript.Echo objSysInfo.Username
Set objNetwork =3D CreateObject("Wscript.Network")
strUserPath =3D "LDAP://" & objSysInfo.UserName
Set objUser =3D GetObject(strUserPath)
For Each strGroup in objUser.MemberOf
strGroupPath =3D "LDAP://" & strGroup
Set objGroup =3D GetObject(strGroupPath)
strGroupName =3D objGroup.CN
'Wscript.Echo strGroupName
'4/12/2005 changes : maps to group drive letter 5/17/2005: added the =
rest of the groups
Select Case strGroupName
Case "Peachtree"
objNetwork.MapNetworkDrive "P:", "\\<servername>\Peachtree"
=20
Case "IT"
objNetwork.MapNetworkDrive "H:", =
"\\<servername>\Departments\IT"
CALL MAPPRINTER("\\<servername>\DEV_EAST_02_BULK")
Case "Membership"
objNetwork.MapNetworkDrive "G:", =
"\\<servername>\Departments\Membership"
CALL MAPPRINTER("\\<servername>\DEV_EAST_02_BULK")
Case "Underwriting"
objNetwork.MapNetworkDrive "G:", =
"\\<servername>\Departments\Underwriting"
Case "Education"
objNetwork.MapNetworkDrive "G:", =
"\\<servername>\Departments\Education"
Case "Engineering"
objNetwork.MapNetworkDrive "G:", =
"\\<servername>\Departments\Engineering"
CALL MAPPRINTER("\\<servername>\ENG_EAST_LFP_01")
Case "Finance"
objNetwork.MapNetworkDrive "G:", =
"\\<servername>\Departments\F&A"
Case "GenMgr"
objNetwork.MapNetworkDrive "G:", =
"\\<servername>\Departments\GM"
Case "Pledge"
objNetwork.MapNetworkDrive "L:", =
"\\<servername>\Departments\Pledge"
Case "Production"
objNetwork.MapNetworkDrive "G:", =
"\\<servername>\Departments\Production"
Case "Reception"
objNetwork.MapNetworkDrive "R:", =
"\\<servername>\Departments\Reception"
Case "Promotions"
objNetwork.MapNetworkDrive "G:", =
"\\<servername>\Departments\A&P"
Case "Pledge"
objNetwork.MapNetworkDrive "G:", =
"\\<servername>\Departments\Pledge"
Case "Traffic"
objNetwork.MapNetworkDrive "T:", =
"\\<servername>\Departments\Traffic"
Case "Westlink"
objNetwork.MapNetworkDrive "W:", =
"\\<servername>\Departments\Westlink"
Case "Programming"
objNetwork.MapNetworkDrive "H:", =
"\\<servername>\Departments\Programming"
Case "Operators"
objNetwork.MapNetworkDrive "O:", =
"\\<servername>\Departments\Operations"
End Select
Next
'4/13/2005 changes: Maps to user's local drive
objNetwork.MapNetworkDrive "U:", "\\<servername>\Users\" & =
objNetwork.UserName
'Sub routine to map common directories
Sub MAPDRIVE(driveletter, drivepath)
On Error Resume Next
If FSO.DriveExists(driveletter) Then
WshNetwork.RemoveNetworkDrive driveletter
End If
WshNetwork.MapNetworkDrive driveletter, drivepath
End sub
'Sub routine to map printers
Sub MAPPRINTER(printerpath)
On Error Resume Next
WshNetwork.addwindowsprinterconnection printerpath
End sub
So what should happen is every user should have a mapping for the =
\users\<username> folder, a mapping for the \departments\<department =
name> and a mapping for \public. =20
Thanks for your help!
------=_NextPart_000_0175_01C5B47E.81ED78F0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2722" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello everyone!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I need help with my script. The =
script runs=20
fine under W2k3 Server. Everyone is set as a Domain User and Local =
Administrator and assigned to different groups under one OU. The =
script is=20
written to map shares to drive letters and map printers. The =
script will=20
run perfectly when a user is part of more than one group. Why is =
this=20
happening? Here is the script (I have substituted =
<servername> for=20
the actual name of the server):</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Dim driveletter, drivepath, =
printerpath<BR>Set FSO=20
=3D WScript.CreateObject("Scripting.FileSystemObject")<BR>Set WshNetwork =
=3D=20
WScript.CreateObject("WScript.Network")<BR>Set objShell =3D=20
CreateObject("WScript.Shell")</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>sDomain =3D =
WshNetwork.UserDomain<BR>strUser =3D =20
UCase(WshNetwork.UserName)<BR>strComputer =3D "."</FONT></DIV>
<DIV> </DIV><FONT face=3DArial size=3D2>
<DIV><BR>'4/13/2005 changes: maps to common directories</DIV>
<DIV> </DIV>
<DIV>CALL MAPDRIVE("Z:","<A=20
href=3D"file://\\<servername>\Public">\\<servername>\Public</A>")<B=
R>CALL=20
MAPDRIVE("Y:","<A=20
href=3D"file://\\<servername>\Apps&Database">\\<servername>\App=
s&Database</A>")</DIV>
<DIV> </DIV>
<DIV>'Maps printers changes: 5/16/2005 added all printer maps<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\ADM_CENTRAL_01">\\<servername>\ADM_CE=
NTRAL_01</A>")<BR>CALL=20
MAPPRINTER("<A =
href=3D"file://\\<servername>\SHARP">\\<servername>\SHARP</A>=20
AR-P450 PCL6")<BR>CALL MAPPRINTER("<A=20
href=3D"file://\\<servername>\ADM_WEST_01">\\<servername>\ADM_WEST_=
01</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\ADM_WEST_02">\\<servername>\ADM_WEST_=
02</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\ADM_CENTRAL_01">\\<servername>\ADM_CE=
NTRAL_01</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\DEV_CENTRAL_01">\\<servername>\DEV_CE=
NTRAL_01</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\DEV_CENTRAL_01_UWCOLOR">\\<servername>=
;\DEV_CENTRAL_01_UWCOLOR</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\DEV_CENTRAL_01">\\<servername>\DEV_CE=
NTRAL_01</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\DEV_EAST_01">\\<servername>\DEV_EAST_=
01</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\DEV_WEST_01">\\<servername>\DEV_WEST_=
01</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\DEV_WEST_02_COLOR">\\<servername>\DEV=
_WEST_02_COLOR</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\ENG_CENTRAL_01">\\<servername>\ENG_CE=
NTRAL_01</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\PROD_CENTRAL_01">\\<servername>\PROD_=
CENTRAL_01</A>")<BR>CALL=20
MAPPRINTER("<A=20
href=3D"file://\\<servername>\PROD_WEST_02">\\<servername>\PROD_WES=
T_02</A>")</DIV>
<DIV> </DIV>
<DIV><BR>'6/30/2005 changes : This section is where drives are mapped =
based on=20
group membership<BR>'4/01/2005 changes : Determines distinguished name =
of user=20
who has logged on.<BR>'4/01/2005 changes : reports what groups user is =
in</DIV>
<DIV> </DIV>
<DIV>On Error Resume Next</DIV>
<DIV> </DIV>
<DIV>Set objSysInfo =3D CreateObject("ADSystemInfo")<BR>'Wscript.Echo=20
objSysInfo.Username<BR>Set objNetwork =3D =
CreateObject("Wscript.Network")</DIV>
<DIV> </DIV>
<DIV>strUserPath =3D "LDAP://" & objSysInfo.UserName<BR>Set objUser =
=3D=20
GetObject(strUserPath)</DIV>
<DIV> </DIV>
<DIV>For Each strGroup in objUser.MemberOf<BR> =
strGroupPath =3D=20
"LDAP://" & strGroup<BR> Set objGroup =3D=20
GetObject(strGroupPath)<BR> strGroupName =3D=20
objGroup.CN<BR>'Wscript.Echo strGroupName</DIV>
<DIV> </DIV>
<DIV>'4/12/2005 changes : maps to group drive letter 5/17/2005: added =
the rest=20
of the groups</DIV>
<DIV> </DIV>
<DIV> Select Case=20
strGroupName<BR> Case=20
"Peachtree"<BR> &nbs=
p; =20
objNetwork.MapNetworkDrive "P:", "<A=20
href=3D"file://\\<servername>\Peachtree">\\<servername>\Peachtree</=
A>"<BR> =20
<BR> Case=20
"IT"<BR>  =
;=20
objNetwork.MapNetworkDrive "H:", "<A=20
href=3D"file://\\<servername>\Departments\IT">\\<servername>\Depart=
ments\IT</A>"<BR> &n=
bsp; =20
CALL MAPPRINTER("<A=20
href=3D"file://\\<servername>\DEV_EAST_02_BULK">\\<servername>\DEV_=
EAST_02_BULK</A>")</DIV>
<DIV> </DIV>
<DIV> Case=20
"Membership"<BR> &nb=
sp; =20
objNetwork.MapNetworkDrive "G:", "<A=20
href=3D"file://\\<servername>\Departments\Membership">\\<servername>=
;\Departments\Membership</A>"<BR> &nbs=
p; =20
CALL MAPPRINTER("<A=20
href=3D"file://\\<servername>\DEV_EAST_02_BULK">\\<servername>\DEV_=
EAST_02_BULK</A>")</DIV>
<DIV> </DIV>
<DIV> Case=20
"Underwriting"<BR> &=
nbsp; =20
objNetwork.MapNetworkDrive "G:", "<A=20
href=3D"file://\\<servername>\Departments\Underwriting">\\<servername&=
gt;\Departments\Underwriting</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Education"<BR> &nbs=
p; =20
objNetwork.MapNetworkDrive "G:", "<A=20
href=3D"file://\\<servername>\Departments\Education">\\<servername>=
\Departments\Education</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Engineering"<BR> &n=
bsp; =20
objNetwork.MapNetworkDrive "G:", "<A=20
href=3D"file://\\<servername>\Departments\Engineering">\\<servername&g=
t;\Departments\Engineering</A>"<BR> &n=
bsp; =20
CALL MAPPRINTER("<A=20
href=3D"file://\\<servername>\ENG_EAST_LFP_01">\\<servername>\ENG_E=
AST_LFP_01</A>")</DIV>
<DIV> </DIV>
<DIV> Case=20
"Finance"<BR> =
=20
objNetwork.MapNetworkDrive "G:", "<A=20
href=3D"file://\\<servername>\Departments\F&A">\\<servername>\D=
epartments\F&A</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"GenMgr"<BR> &=
nbsp;=20
objNetwork.MapNetworkDrive "G:", "<A=20
href=3D"file://\\<servername>\Departments\GM">\\<servername>\Depart=
ments\GM</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Pledge"<BR> &=
nbsp;=20
objNetwork.MapNetworkDrive "L:", "<A=20
href=3D"file://\\<servername>\Departments\Pledge">\\<servername>\De=
partments\Pledge</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Production"<BR> &nb=
sp; =20
objNetwork.MapNetworkDrive "G:", "<A=20
href=3D"file://\\<servername>\Departments\Production">\\<servername>=
;\Departments\Production</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Reception"<BR> &nbs=
p; =20
objNetwork.MapNetworkDrive "R:", "<A=20
href=3D"file://\\<servername>\Departments\Reception">\\<servername>=
\Departments\Reception</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Promotions"<BR> &nb=
sp; =20
objNetwork.MapNetworkDrive "G:", "<A=20
href=3D"file://\\<servername>\Departments\A&P">\\<servername>\D=
epartments\A&P</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Pledge"<BR> &=
nbsp;=20
objNetwork.MapNetworkDrive "G:", "<A=20
href=3D"file://\\<servername>\Departments\Pledge">\\<servername>\De=
partments\Pledge</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Traffic"<BR> =
=20
objNetwork.MapNetworkDrive "T:", "<A=20
href=3D"file://\\<servername>\Departments\Traffic">\\<servername>\D=
epartments\Traffic</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Westlink"<BR>  =
; =20
objNetwork.MapNetworkDrive "W:", "<A=20
href=3D"file://\\<servername>\Departments\Westlink">\\<servername>\=
Departments\Westlink</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Programming"<BR> &n=
bsp; =20
objNetwork.MapNetworkDrive "H:", "<A=20
href=3D"file://\\<servername>\Departments\Programming">\\<servername&g=
t;\Departments\Programming</A>"</DIV>
<DIV> </DIV>
<DIV> Case=20
"Operators"<BR> &nbs=
p; =20
objNetwork.MapNetworkDrive "O:", "<A=20
href=3D"file://\\<servername>\Departments\Operations">\\<servername>=
;\Departments\Operations</A>"</DIV>
<DIV> </DIV>
<DIV><BR> End Select<BR>Next</DIV>
<DIV> </DIV>
<DIV>'4/13/2005 changes: Maps to user's local drive</DIV>
<DIV> </DIV>
<DIV>objNetwork.MapNetworkDrive "U:", "<A=20
href=3D"file://\\<servername>\Users\">\\<servername>\Users\</A>" =
&=20
objNetwork.UserName</DIV>
<DIV> </DIV>
<DIV><BR>'Sub routine to map common directories</DIV>
<DIV> </DIV>
<DIV>Sub MAPDRIVE(driveletter, drivepath)<BR> On Error Resume=20
Next<BR> If FSO.DriveExists(driveletter)=20
Then<BR> WshNetwork.RemoveNetworkDrive =
driveletter<BR> End=20
If<BR> WshNetwork.MapNetworkDrive driveletter, =
drivepath<BR>End=20
sub</DIV>
<DIV> </DIV>
<DIV><BR>'Sub routine to map printers</DIV>
<DIV> </DIV>
<DIV><BR>Sub MAPPRINTER(printerpath)<BR> On Error Resume=20
Next<BR> WshNetwork.addwindowsprinterconnection printerpath<BR>End=20
sub</DIV>
<DIV> </DIV>
<DIV>So what should happen is every user should have a mapping for the=20
\users\<username> folder, a mapping for the =
\departments\<department=20
name> and a mapping for \public. </DIV>
<DIV> </DIV>
<DIV>Thanks for your help!</FONT></DIV></BODY></HTML>
------=_NextPart_000_0175_01C5B47E.81ED78F0--