Advertisement

09.24.2008 at 03:56AM PDT, ID: 23758095
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

Login Script to Set Default Printer

Asked by matthewcramer in VB Script, Visual Basic Programming

Tags: , ,

Hi All

I have a working login script which maps network drives and printers according to the user accounts group memberships. This is all fine. I am running into difficulty with setting the Default Printer for users via the script.

Users have different default printers depending on their department. Is it possible to have this one script set the Default Printer according to which department (group membership) the user is in? (I realise I could just have multiple login scripts, but would rather keep in to this one)

I have included the relevant part of the script below.

Thanks in advance for any/all assistance. If you need more information from me, please ask.

NB. I am by no means an advanced VB Scripter... Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
'Deletes ALL existing network printers
 
On error Resume Next
 
Dim objNetwork
Dim strComputer
 
strComputer="."
Set objNetwork = CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery("Select * from Win32_Printer")
 
For Each objPrinter in colInstalledPrinters
      Printer = objPrinter.name
      objNetwork.RemovePrinterConnection Printer
next
 
'**********************
 
'Map network drives
'**********************
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_OffersCompl") Then MapIt "E:","\\Server02\offerscompl"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"Domain Users") Then MapIt "P:","\\Server02\public"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_Accounts") Then MapIt "S:","\\Server02\sage"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"Domain Users") Then MapIt "T:","\\Server02\data"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_Underwriters") Then MapIt "U:","\\Server02\underwriting"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_EDS") Then MapIt "X:","\\Server02\eds"
 
'Map printers
'**********************
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_Accounts") Then AddPrinterConnection "\\DNSThree\Accounts - Colour"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_Accounts") Then AddPrinterConnection "\\DNSThree\Accounts Printer"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_BusSup") Then AddPrinterConnection "\\DNSThree\Business support"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_Completions") Then AddPrinterConnection "\\DNSThree\Completions"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_Ecom") Then AddPrinterConnection "\\DNSThree\E-commerce Printer"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_11thFloor") Then AddPrinterConnection "\\DNSThree\Edge Headed"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_11thFloor") Then AddPrinterConnection "\\DNSThree\Edge Headed 2"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_EFL") Then AddPrinterConnection "\\DNSThree\Enterprise Finance"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_EFL") Then AddPrinterConnection "\\DNSThree\Enterprise Finance2"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_BusSup") Then AddPrinterConnection "\\DNSThree\ESURV"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_Facilities") Then AddPrinterConnection "\\DNSThree\Partners colour"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_11thFloor") Then AddPrinterConnection "\\DNSThree\Plain 1"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_11thFloor") Then AddPrinterConnection "\\DNSThree\Plain 2"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_BusSup") Then AddPrinterConnection "\\DNSThree\Spinnaka"
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_LocalLorna") Then AddPrinterConnection "\\DELL_150607\Lorna"
 
###########################################################
############## BELOW IS NOT PART OF SCRIPT ################
 
I know this can be used as an example of setting a Default Printer, but it will set the same Default for all users - NOT what I want. What needs to be changed/amended?
 
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserName,"_ITSupport") Then AddPrinterConnection "\\10.0.0.163\IT Support"
objNetwork.SetDefaultPrinter "\\10.0.0.163\IT Support"
 
###########################################################
###########################################################
[+][-]09.24.2008 at 06:37AM PDT, ID: 22559521

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.

 
[+][-]09.24.2008 at 06:56AM PDT, ID: 22559704

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.

 
[+][-]09.24.2008 at 07:31AM PDT, ID: 22560087

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.

 
[+][-]09.24.2008 at 07:37AM PDT, ID: 22560154

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

Zones: VB Script, Visual Basic Programming
Tags: VB Script, VBS, -, user login script for Windows 2003 AD domain
Sign Up Now!
Solution Provided By: JonMny
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.24.2008 at 08:12AM PDT, ID: 22560536

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.

 
[+][-]09.24.2008 at 08:28AM PDT, ID: 22560722

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.

 
[+][-]09.24.2008 at 09:14AM PDT, ID: 22561238

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...
20081112-EE-VQP-42 / EE_QW_2_20070628