none
Group Policy - Computer Startup Scripts - Add/Set Default printer

    Question

  • Good Morning.

    Let's say we have 2 offices, A and B, and only 1 user.  The user is using Roaming Profiles.  Each office has its own printer.

    What I am trying to do, is make a Startup script that is specific to the COMPUTER being logged into so when any user logs into that computer, they get the printer in that office defined and set as default.

    I am able to do this successfully with my script but ONLY if i have the script be on the USER side of GP (i.e. in the Logon script section)

    That is great that that is working however, when my user goes to Office B, they still get mapped to Office A's printer if I use that method.

    So I figured I could just modify my GP and run the same script from the STARTUP section of the computer, rather than the LOGON section of the user.  It does not work.

    Here is my script:


    Set WRFCUNetwork = CreateObject("Wscript.Network")
    PrinterPath = "\\fileserver\MAINTELLER"
    PrinterDriver = "PrinterDriver"
    WRFCUNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver
    WRFCUNetwork.SetDefaultPrinter "\\fileserver\MAINTELLER"

    This is where I Have the script placed:
         Computer Configuration -> Windows Settings -> Scripts(Startup/Shutdown)

    Once i'm in there, I double click Startup, click Add, and select my script which is named:
         MainPrinterSetup.vbs

    I have this GP applied to ONE OU, and that OU has ONE computer in it (my test computer)
    I login with a brand new user called "testuser" (creative, huh?) and basically nothing happens
    except they log in and have some Microsoft Document Image Writer printer set as default (which by the way sure does slow the PC down to the point of it almost being broke if anyone actually tries to print to that by accident)

    No Main Teller Printer, no anything.

    The strangest part about this is, if i apply this script to the user LOGON scripts, it works fine, the printer is there, and is set as default. (but see above why that wont work for my situation)

    So obviously the script works fine, but I guess i'm missing something when it comes to applying GP's to Computers rather than Users.

    Can anyone shed some light as to why the script is not running (i'm guessing the script isn't even attempting to run, rather than failing, but i have no way to know that)

    Thank you in advance!!

    Derek Conlon
    Network Administrator
    WRFCU


    EDIT:  Here are the PC's info that i'm working on:
         Server:  Windows Server 2003 Standard Edition (where my GP's are created and managed with AD)
         Target PC:  Windows XP Professional SP3

    EDIT #2:  I manually navigated to the Script file after logging in and "opened" it and it added and set the default printer no problem.  the issue is definately with the script running at startup.
    Wednesday, November 04, 2009 4:59 PM

Answers

  • Hi Derek,
     I believe that printer connections in general are per user so I'm not sure what you're trying to do is possible without some additional logic in the code for a user login. 

    If you have a Windows 2008, Windows 2008 R2, Vista or Windows 7 system to manage the GPOs from, you can use GPO preferences to map a printer for users. By creating a GPO linked to the AD site, you can configure a computer printer connection and set it as default in the following spot: Computer Configuration/Preferences/Control Panel Settings/Printers.

    Guy
    • Marked as answer by Derek Conlon Wednesday, November 04, 2009 7:31 PM
    Wednesday, November 04, 2009 5:28 PM

All replies

  • Hi Derek,
     I believe that printer connections in general are per user so I'm not sure what you're trying to do is possible without some additional logic in the code for a user login. 

    If you have a Windows 2008, Windows 2008 R2, Vista or Windows 7 system to manage the GPOs from, you can use GPO preferences to map a printer for users. By creating a GPO linked to the AD site, you can configure a computer printer connection and set it as default in the following spot: Computer Configuration/Preferences/Control Panel Settings/Printers.

    Guy
    • Marked as answer by Derek Conlon Wednesday, November 04, 2009 7:31 PM
    Wednesday, November 04, 2009 5:28 PM
  • Ugh.  That is not what I wanted to hear.

    I have a question then.

    There are always printer's showing up like Microsoft Document Image Writer, in the printers/faxes folder, even if the user was JUST created and has never logged onto any machine, ever.

    Where are the information for THOSE "printers" stored? perhaps I could add an entry into the registry of the computer itself and do it that way instead of using GP?

    I mean, i would definately rather use GP to do *everything* just for management reasons, but we aren't switching our machines to Windows 7 for at least a year or more and I dont know if our DC will be off of 2003 in the next 5 years even.

    It would seem that my best option to be able to continue using GP to achieve my goals is to learn to write some more complicated VBscript so i can do what i want (any suggestions or links on that would be helpful) but do you know where those "default" printers that show up on any user (even if the user is brand new and never logged into a machine before) are at?  that might be a temporary fix until I can learn some VBS.

    Thanks Guy!!!!!

    Derek Conlon
    Network Administrator
    WRFCU - Colorado
    Derek Conlon Network Administrator WRFCU - Colorado
    Wednesday, November 04, 2009 5:40 PM
  • Derek,
     Note that in order to use GPO preference, you don't need to upgrade your DCs or your workstations. You just need a single Windows 2008, Windows 2008 R2, Vista or Windows 7 to create/manage the GPO and Windows XP SP3 (or even SP2 with the CSE update) on the clients using the GPO.

    Physical printer definitions, including the Document Image Writer and and connected devices are configured at the computer level but 'mapped' printers are at the user level just like mapped drives.

    Guy
    Wednesday, November 04, 2009 5:49 PM
  • Guy,

    Thanks for all your help.

    I only have 1 Vista Business machine on our network that I can access and it is a hotspare so I cant put any management tools on it.

    I have done some research into the VBScript side of things and it seems I can use VBScript to determine the Hostname of the PC the user is logging into.  In our network the PC's are named depending on what office they are in, PC1X for main office, PC2X for 2nd office, etc etc.  with some simple code (thought it would be hard, but nope) I can get the hostname then with some simple IF/THEN's, map printers accordingly for the user logging in.

    THANK YOU VERY MUCH for your help.  I have marked your first response as the answer because you were dead on :)

    I appreciate it much!!!
    Derek Conlon Network Administrator WRFCU - Colorado
    Wednesday, November 04, 2009 7:34 PM
  • Hi Guy,

    Where are the new preferences saved? i.e if you manage it from a single windows 2008 R2 server and it dies, what happens to the settings? Are they stored in AD even though the 2003 DC's don't know about them?

    And if you then create a new 2008 server or a windows 7 pc and install the group policy management console onto them will you see all the settings you made on the one that died? even if for a time there were no machines that were capable of managing the new preferences.

     

    THanks,

    Michael.

    Saturday, August 14, 2010 4:04 AM
  • I wanted to clarify a few things:

    1. While it is true that printer connections are usually per user, it is definitely possible to create "global printers".  There are a number of ways to do this, but two methods that come to mind are using:

    a. "Rundll32 printui.dll,PrintUIEntry" option with the "/ga" switch.  The "/ga" switch is the key here since it allows you to deploy printers "per machine" instead of "per user".  More information about this is available at:
    http://members.shaw.ca/bsanders/NetPrinterAllUsers.htm
    http://technet.microsoft.com/en-us/library/ee624057%28WS.10%29.aspx
    http://www.computerperformance.co.uk/Logon/logon_printer_computer.htm
    http://www.robvanderwoude.com/2kprintcontrol.php

    b. The Print Management console that is available in Windows 2003 R2 and higher can help you deploy printers "per machine" in addition to "per user".  More information about this is available at:
    http://www.czsolution.com/print-management/print-management/print-management-console.htm#DeployingPrintersByGroupPolicy
    http://technet.microsoft.com/en-us/library/cc753109%28WS.10%29.aspx

    2. As Guy mentioned, Group Policy Preferences can help set the default printer.  But there is another way to accomplish this.  The problem with the computer startup portion is that it runs before the user logs in.  And applying this script in the login script section would not work per computer unless you used loopback processing.  So another way to do this is to place a script that sets the default printer into the "All Users" startup folder.  Items in the "All Users" startup folder run for any user that logs into the computer, but it runs in the user's context.  So, this script would effectively set the default printer on a "per machine" basis.  The script method is a cruder way to approach the problem, but it will help get the job done.  Here are some resources on setting the default printer via script:
    http://www.intelliadmin.com/index.php/2007/08/set-default-printer-from-a-script
    http://www.computerperformance.co.uk/ezine/ezine17.htm

    Monday, August 16, 2010 4:48 AM