+ Post New Thread
Results 1 to 7 of 7
Scripts Thread, logon script for printer in Coding and Web Development; Any help would be recieved with open arms!!!! Just put the following logon script to map a printer in a ...
  1. #1
    ozzy's Avatar
    Join Date
    Oct 2007
    Thank Post
    Thanked 39 Times in 36 Posts
    Rep Power

    logon script for printer

    Any help would be recieved with open arms!!!!
    Just put the following logon script to map a printer in a OU GPO that I have been using to test policys before deploying them to a new domain, it worked fine with test user account but when I added another user to the OU nothing!!!!

    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.AddWindowsPrinterConnection "\\europa\itlaser"
    objNetwork.SetDefaultPrinter "\\europa\itlaser"

    any ideas, PLEASE.

  2. #2

    Join Date
    Sep 2006
    Thank Post
    Thanked 34 Times in 32 Posts
    Rep Power

    Re: logon script for printer

    Is the other user you have added a memebr Domain Admin security group?

    Also check the security filtering on the GPO

  3. #3

    Ric_'s Avatar
    Join Date
    Jun 2005
    Boston, MA
    Thank Post
    Thanked 770 Times in 598 Posts
    Rep Power

    Re: logon script for printer

    Also check out http://edugeek.net/index.php?name=Fo...iewtopic&t=404 for lots of info on this (and a ready made script that works!)

  4. #4

    Join Date
    Mar 2007
    Central Scotland
    Thank Post
    Thanked 8 Times in 8 Posts
    Rep Power

    Re: logon script for printer

    This is the printer script I use, adds the printer depending on the OU the computer in, rather than the user. Works great in here, add printer to server, add it to script, job done, it'll add itself to any computers in that department from then on.

    Created with help from EDUGeek chaps:

    on error resume next
    'Set variables.

    Set shell= WScript.CreateObject("WScript.Shell")
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    dim Counter, PrinterPath
    Set objWshNetwork = CreateObject("WScript.Network")
    Set objAdsSystemInfo = CreateObject("adsysteminfo")
    Set objComputerName = GetObject("LDAP://" & objAdsSystemInfo.ComputerName)
    Set objOU = GetObject(objComputerName.Parent)
    strOU = replace(objOU.Name,"OU=","")
    Set oPrinters = WshNetwork.EnumPrinterConnections

    Dim computerName
    computerName = LCase(WshNetwork.ComputerName)

    'Add printers depending on AD OU containing computer.

    Select Case strOU
    Case "IT1"
    addPrinter "\\print\Dell1700 IT1",True
    addPrinter "\\print\HP2500C IT1",False
    Case "IT2"
    ' removePrinters
    addPrinter "\\print\HP LJ P2015n IT2",True

    end select

    function removePrinters()

    FOR Counter = 0 to oPrinters.Count - 1
    IF mid(oPrinters.Item(Counter), 1, 2) = "\\" THEN
    PrinterPath = oPrinters.Item(Counter)
    WshNetwork.RemovePrinterConnection PrinterPath, True, True
    end if

    end function

    function addPrinter(strConnectString,isDefault)

    if strConnectString <> "" then
    strResult = WshNetwork.AddWindowsPrinterConnection(strConnectS tring)
    if isDefault then
    WshNetwork.SetDefaultPrinter strConnectString
    end if
    end if
    end function


    The true/false statements after the printer name dictate whether it's set as default or not. "removeprinters" only removes network and not local printers.

  5. #5

    Re: logon script for printer

    Here is an example of a script we use for the LRC.
    Note: The word school refers to the name of your server you use at your place.

    rem ** Next line must not be deleted **
    Set WshNetwork = CreateObject("WScript.Network")

    rem ** This will delete existing printers **
    On Error Resume Next
    Set oPrinters = WshNetwork.EnumPrinterConnections
    For i = 1 to oPrinters.Count - 1 Step 2
    WshNetwork.RemovePrinterConnection oPrinters.Item(i)

    rem ** Setup new printer connection **
    WshNetwork.AddWindowsPrinterConnection "\\SchoolPrint.School.local\LRC"

    rem ** Setup default printer **
    WshNetwork.SetDefaultPrinter "\\SchoolPrint.School.local\LRC"
    MsgBox "Added Printer: LRC. This printer is default"

  6. #6
    mullet_man's Avatar
    Join Date
    Oct 2005
    Thank Post
    Thanked 48 Times in 46 Posts
    Rep Power

    Re: logon script for printer

    Use Ric_'s script, we have been using it here and it does the job perfect, not had one problem.

    Cheers Ric_ :-)

  7. #7
    mrforgetful's Avatar
    Join Date
    May 2006
    Thank Post
    Thanked 15 Times in 15 Posts
    Rep Power

    Re: logon script for printer

    We use the R2 functionality of Server 2003 R2.

    Before that I ran a script on the computer itself after imaging which would add the printer for anyone who logged on.

+ Post New Thread

Similar Threads

  1. Replies: 8
    Last Post: 25th February 2009, 10:50 AM
  2. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 12:00 PM
  3. BGInfo in logon script example?
    By ninjabeaver in forum How do you do....it?
    Replies: 16
    Last Post: 24th August 2007, 01:49 PM
  4. Yet another Logon Script
    By ajbritton in forum Windows
    Replies: 3
    Last Post: 19th June 2006, 10:47 AM
  5. Stupid CMD error with logon script
    By tarquel in forum Windows
    Replies: 37
    Last Post: 14th June 2006, 10:07 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts