3

Win 2003 R2 setup. I can push the printer via group policy, and pushprinterconnections.exe, but the printer isn't set as the default printer. Any ideas on how to set the default printer for an XP box via group policy?

David Pashley
  • 23,151
  • 2
  • 41
  • 71
WaldenL
  • 1,248
  • 1
  • 14
  • 26

4 Answers4

3

In the past I've done this using a startup script.

Using wscript:

    Set WSHNetwork = CreateObject("WScript.Network")
    WSHNetwork.SetDefaultPrinter "[PRINTER_NAME]"

Taken from this link

Jimmie R. Houts
  • 1,853
  • 1
  • 15
  • 12
  • Nice! Only problem is one of timing. It seems that the printer, pushed from group-policy, isn't yet completey installed when the script runs, as I get an error that the printer doesn't exist. – WaldenL May 04 '09 at 22:29
  • OK, my bad. I had the script set the default printer as "Canon5000_PCL" which is the printer name... or was it? :-) Printer name is actually "\\\Canon5000_PCL", really helps to have the UNC path in the name. Your solution seems spot on (if one uses the right printer name) :-) – WaldenL May 05 '09 at 13:04
  • 1
    To make it more flexible, you could create a security group for each printer - and then add the user to one of the printer security groups - having your script checking which printer group the user belongs to, setting that one as default. Instant default printer management with ADUC ^^ – Oskar Duveborn May 20 '09 at 00:37
  • To add the printer connection, before setting it as default, add: WSH.Network.AddWindowsPrinterConnection("[Printer_UNC_PATH]") – Nathan Hartley Jun 18 '10 at 14:12
1

In your comment on this answer you mention an issue with timing. On our systems I call the script that sets default printers by adding the script under

User Configuration - Templates - System/Logon - Run Programs at Logon

The programs under 'run programs at logon' happen after the profile is done loading, and after windows explorer has started. I am not 100% certain that this will deal with the timing issue in all cases, but it works for me.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
0

We have school districts using R2 printing deployment for labs. To combat this left out function from R2 we use Kixtart to help. This will help is you deploy printers for users in specific labs. This will also provide the delay needed to wait for windows to add the printer.

Labs have a naming convention. HS101-01, HS101-02, HS102-01, HS102-02, etc

Using a kixtart startup script from a Group Policy Object we have kix32.exe execute this script below.

;Capture room number
$pos = INSTR(@WkSta, "-");
IF $pos > 0
    $Room = LEFT(@WkSta, ($pos - 1));
    ; ? $Room
ELSE
    $Room = @WkSta;
ENDIF


SLEEP 45   ; Give the computer time to log in and add the printer

;;;;;;;;;;;;; BEGIN PRINTER DEFAULTS LIST ;;;;;;;;;;;;

SELECT

    Case $Room = "HS71"
        SetDefaultPrinter("\\nebsdfs\HS71 - HP LaserJet 4100 Series PCL")

    Case $Room = "HS086"
        SetDefaultPrinter("\\nebsdfs\HS086 - HP LaserJet 4000")

    Case $Room = "ES102"
        SetDefaultPrinter("\\nebsdfs\ES102 - HP LaserJet 4000")


ENDSELECT

;;;;;;;;;;;;;; END PRINTER DEFAULTS LIST ;;;;;;;;;;;;;

I hope this will help. Thanks.

Zach
  • 41
  • 2
0

This is a surprisingly annoying problem to solve. The first problem is that the default printer setting is user specific. The second problem like you noted in your comment to Jimmie is that even with a per-user login script, there are timing issues where the printer doesn't technically exist yet or the HKCU hive hasn't finished loading.

What we ended up doing in our situation is basically using a login script that loops looking for the printer to exist before it tries to set it as default. If it can't find it after a certain amount of time, it just gives up.

Ryan Bolger
  • 16,472
  • 3
  • 40
  • 59