Advertisement

05.20.2008 at 01:41PM PDT, ID: 23418775
[x]
Attachment Details

VBS Script to Map Printer Based on Group Membership

Asked by jlepre in Active Directory

Tags: Microsoft, Active Directory, 2003, VBS

Hello,

I am trying to create a VBS Logon Script to map printers based on group membership.  I have two groups and two printers called PrinterA and PrinterB.  When I run the script I do not get any printer mappings or any error messages.  Any ideas on why this does not work?

Thanks in advance.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Const PrinterA ="cn=PrinterA"
Const PrinterB = "cn=PrinterB"
 
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
 
If InStr(strGroups, PrinterA) Then
 
    wshNetwork.AddWindowsPrinterConnection "\\W2k8-INT\PrinterA"
    wshNetwork.AddWindowsPrinterConnection "\\W2k8-INT\PrinterB"
    wshNetWork.SetDefaultPrinter "\\W2k8-INT\PrinterA"
 
ElseIf InStr(strGroups, PrinterB) Then
 
    wshNetwork.AddWindowsPrinterConnection "\\W2k8-INT\PrinterB"
    wshNetwork.AddWindowsPrinterConnection "\\W2k8-INT\PrinterA"
    wshNetWork.SetDefaultPrinter "\\W2k8-INT\PrinterB"
 
End If
[+][-]05.20.2008 at 01:50PM PDT, ID: 21610226

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 01:54PM PDT, ID: 21610247

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 02:05PM PDT, ID: 21610330

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Directory
Tags: Microsoft, Active Directory, 2003, VBS
Sign Up Now!
Solution Provided By: tanelorn
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.21.2008 at 06:16AM PDT, ID: 21614657

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 06:38AM PDT, ID: 21614886

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628