1

I've got a login script setup, that removes all old printers, and then adds the current set of network printers.

CODE

Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
  If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
    WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
  End If
Next

'Install Network Printers
WSHNetwork.AddWindowsPrinterConnection "\\SERVER\PRINTER1"
WSHNetwork.AddWindowsPrinterConnection "\\SERVER\PRINTER2"
WSHNetwork.AddWindowsPrinterConnection "\\SERVER\PRINTER3"
WSHNetwork.AddWindowsPrinterConnection "\\SERVER\PRINTER4"

This is fine, but seems to reset the current default printer on the users machine.

Is there a way to preserve the current default printer on the users machine?

Is this the most sensible way to confer network printers for users upon login? Or are there alternative or better ways to do so?

Any help is very much appreciated.

spelk
  • 87
  • 1
  • 4
  • 10

3 Answers3

1

Why use a script at all?

I roll out printer configurations (and mapped drives) using the client extensions of the group policy mechanism (that was introduced some long time ago and is part of all windows updates since years).

TomTom
  • 50,857
  • 7
  • 52
  • 134
  • Can you be more specific? Can you please link to a guide? Thanks – Jindrich Mar 10 '10 at 09:44
  • http://blog.mpecsinc.ca/2008/12/sbs-2008-group-policy-client-side.html – TomTom Mar 10 '10 at 10:22
  • Are the Client Side Extensions of GP only available through Windows Server 2008? We're running Windows Server 2003 SP2 at the moment. I'd be very interested in taking the setup of Printers and Drive mappings out of a login script and into some sort of formal Group Policy, but I haven't any clue how to do it, or where to start. – spelk Mar 11 '10 at 12:44
  • They should be available in 2003 / XP. Separate downloads, though (as in: if your systems are fully patched, they should be there). – TomTom Mar 11 '10 at 12:49
1

I use an old exe that came in the WinNT resource kit called con2prt.exe.

The best way to call it would be from your VBS login script as follows:

'Mapping printers needed by everyone
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run ("\\SERVER\SYSVOL\SERVER.local\scripts\map_printers.bat")

And the Map_Printers.bat should contain

:: Map Printers
: HP 1600
\\SERVER\SYSVOL\server.local\scripts\con2prt.exe /cd \\SERVER\HP1600
:: Ricoh Aficio 2035e 
\\SERVER\SYSVOL\server.local\scripts\con2prt.exe /c \\SERVER\RICOH2035
:: Samsung ML-2010
\\SERVER\SYSVOL\server.local\scripts\con2prt.exe /c \\SERVER\SamsML2010
:: HP BusinessInket 2230
\\SERVER\SYSVOL\server.local\scripts\con2prt.exe /c \\SERVER\HP2230

The /cd means set deafult.

You can find out all the commands by running con2prt.exe /?

Also - you can download here : http://www.paulmcgrath.net/download.php?view.2

0

Last time I scripted that, I added a group for each printer in AD - then added the user to whatever printer group was suppose to be his or her default - and in the login script checked for this group membership, setting the appropriate default.

Obviously, that environment was pretty fixed so this was easy to determine - putting the burden on setting a default printer on the templates instead of the poor user (who could still temporarily change it manually when needed). A more obvious approach might be to check what the default printer is before removing the printers, and then (if that printer still exists after your script) re-apply the default printer setting.

But as TomTom writes, these days printers can be connected using group policies - and then you shouldn't experience any of your mentioned problems anyway.

I also recall doing a registry dump of the Printers registry key and then just importing it being stupendously fast, if you've got the possibility to freeze system configurations (like on a TS) it's quite fun, though not very maintainable ;)

Oskar Duveborn
  • 10,740
  • 3
  • 32
  • 48
  • I've since modified the login script itself to do exactly what you suggested. However, we have a number of users who have local printers that will be set as default, and presumably the login script will rejig these around. I've read that removing network printers and adding them again is a good practice because it prevents some problems with multiple SPOOLSS, but if there was a way to circumvent this seemingly arcane practice in login scripts, and manage it with GP I'd be very interested to hear about how to go about it, or be pointed in the right direction. – spelk Mar 11 '10 at 12:49