• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1005
  • Last Modified:

Logon Script - map printers based on location

Depending on which DC users logon from (they are in different locations on different subnets, of course)....
can I map printers based on where users logon location?

If I'm in LA, map LA printers
If I'm in NYC, map NYC printers.  I don't want them getting printer connections and then printing to the mystery printer cross country LOL

Thanks
0
OnsiteSupport
Asked:
OnsiteSupport
  • 4
  • 3
  • 3
  • +2
1 Solution
 
beechy_Commented:
If your servers are 2003 R2 or later you can use group policy to deploy printers and set the policies on your site objects to deploy different printers to different locations.

http://www.windowsnetworking.com/articles_tutorials/Deploying-Printers-Group-Policy-Windows-R2.html
0
 
gemartiCommented:
First you'll have to make sure that your administrators in LA and NYC grant the user permission the the shared resource.

A little more involved that but I think I've covered all you need:
1. Get IP address of machine
2. Determine Location
3. Check if printer is already referenced on the machine and if not install it
4. Set the printer as default printer

You'll have to do a little reading; I didn't want to plagiarize some one else's work so links to different scripts are within the script posted below.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Your script will have to do the following:

//Get the IP address of the machine the user is logging into the network with:

DIM IPLocation

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set IPConfigSet = objWMIService.ExecQuery _

    ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
 
For Each IPConfig in IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then

        For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)

            WScript.Echo IPConfig.IPAddress(i)

        //Determine if IP address in in LA or NYC
 //Convert IPConfig.IPAddress(i) to Binary  SEE HERE: http://www.indented.co.uk/index.php/2008/10/21/vbscript-subnet-math/

        if BinaryIP > NYCBinaryIPS and < NYCBinaryIPS then
       
          IPLocation = NYC
        else
     
         IPLocation = LA
        end if
 
           Select Case IPLocation
         
           Case LA
               //Check if LA printer is already installed If not install it.
               //See Here: http://www.tek-tips.com/viewthread.cfm?qid=551578&page=1
               //Set as default printer
              //See Here: http://www.computerperformance.co.uk/Logon/LogonScript_Printer_Bonus.htm
            Case NYC
               //Check if NYC Printer is already installed if not install it.
              //See Here: http://www.tek-tips.com/viewthread.cfm?qid=551578&page=1
              //Set as default printer
              //See Here
           
          End Select
        Next
    End If
Next



0
 
greg wardSystems EngineerCommented:
Or you could use this

Option Explicit
Dim objPrinters, objShell, objNetwork, strUNCPrinter1, strUNCPrinter2
 
ON ERROR RESUME NEXT
 
Set objPrinters = WScript.CreateObject("WScript.Network")
Set objShell = WScript.CreateObject("WScript.Shell")
 
 
strUNCPrinter1 = "\\server\printer"
strUNCPrinter2 = "\\server\printer"

Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection strUNCPrinter1
objNetwork.SetDefaultPrinter strUNCPrinter1
 
WScript.Quit
 
copy the file using unc to the all users start up folder and everyone gets the right printer and it gets a default one too.
 
Greg
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
OnsiteSupportAuthor Commented:
Greg-
what is calculating which printer they should get?
0
 
greg wardSystems EngineerCommented:
strUNCPrinter1 = "\\server\printer"
change to
strUNCPrinter1 = "printserver\printershare"
Greg
 
0
 
OnsiteSupportAuthor Commented:
I've left out an important piece in the description.  Users from NYC visit LA and want to logon, get their drive mappings, print to the local printers.

Deepdraw....I like your concept, except how will I deploy the VB script to the correct location based on their locale?...it can't be based on OU membership.

Can I get the Logon server name when they logon?

Many thanks
0
 
maco008Commented:
Have you tried using Group Policy preferences?  You can do a target by IP Address range and you can also set the default printer based on their location (through IP address).
Assuming that NYC and LA branches have different subnets (should be).

Check this out.

http://www.grouppolicy.biz/tag/printer/

For group policy preferences, you can check out this link

http://www.windowsnetworking.com/articles_tutorials/Group-Policy-Preferences-Get-Them-Running-Today.html
0
 
OnsiteSupportAuthor Commented:
maco-
Looks like this is only available on Windows Server 2008...am I correct?
0
 
maco008Commented:
nope. u only need vista or higher OS version to manage it and see the option. domain can be 2k3 and u just need to install the extensions on clients lower than vista.
0
 
OnsiteSupportAuthor Commented:
Maco....extensions...can you point me to the right documentation for this piece?
0
 
maco008Commented:
http://www.windowsnetworking.com/articles_tutorials/Group-Policy-Preferences-Get-Them-Running-Today.html

This article is pretty good and explains everything.  As what he said (never tried though) you can even use this on a 2k domain.  Just check the part "Getting the CSE Installed Correctly" for instructions.   You can download the KB links and install it manually or use WSUS to install it automatically (just search group policy extension).

First you need to have at least a vista workstation, you don't need to have a 2k8 server to do this, then install GPMC on your vista or windows 7.  You should be able to see "Preferences" through vista/windows 7 gpmc.

Here's the article on how to install GPMC/RSAT on vista.
http://www.windowsecurity.com/articles/Installing-Using-Remote-Server-Administration-Tools-RSAT-Vista.html
0
 
greg wardSystems EngineerCommented:
Hi
This script just sits on the machine in the all users start up and does not require domain membership.
 
Greg
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now