Jump to content

Inconsistent mapping of printers using Group Policy Preferences


Recommended Posts

Posted

This is really starting to wind me up!

 

Have a number of users in an OU, linked to a Group Policy which specifies a printer mapping Group Policy user preference.

 

It works fine, however random machines suddenly decide they don't want to map the printers (Typically during exams!!) - The weird thing is, if I then log in as Administrator, restart the 'Print Spooler' service on the workstations then log back in as the user and force a gpupdate the mappings decide to then...map!

 

If I try to add a shared printer manually by browsing to it and double clicking it the machine thinks about it a while then throws an error 'The specified port is unknown' (Before the print spooler restart process mentioned above).

 

Does anyone have any suggestions as I simply cannot be present every exam to go round restarting Print Spooler services!

 

All workstations are Windows 7 in a 2008 R2 domain functional level.

 

The printer (driver) in question if it makes any difference is a HP LaserJet P2015

Posted

What is your print server?

 

Do you have win7 drivers installed on it?

 

Are your clients 32bit or 64bit do you have the relevant version of the driver installed?

 

Ben

Posted

OK.

 

I found a print mapping VBS script on here, and have modified it as below:

 

'Name : addprinter.vbs

'Author : Matt Davies

'Date : 22/03/2006

'Description : - Used to add printers for a user

' - Used inconjunction with group policy at Workstation level so it runs per room

' - Needs to be run under "USER" Logon scripts

Option Explicit

Dim objNetwork

'declare the printer names - add as necessary

Dim strUNCPrinter1

'Dim strUNCPrinter2

'set the UNC path to the printers you want mapped - add as necessary

strUNCPrinter1 = "\\print\MFD_Pull_Queue"

'strUNCPrinter2 = "\\ygg-printers\5170-Cymraeg"

Set objNetwork = CreateObject("WScript.Network")

'remove old printer(s) first

'for debugging comment out next line only

on error resume next

objNetwork.RemovePrinterConnection strUNCPrinter1

'objNetwork.RemovePrinterConnection strUNCPrinter2

'Wait 3 seconds whilst windows removes the old printers

wscript.sleep(3000)

'Add the printer to the computer - add as necessary

objNetwork.AddWindowsPrinterConnection strUNCPrinter1

'objNetwork.AddWindowsPrinterConnection strUNCPrinter2

' Here is where we set the default printer - change if necessary

objNetwork.SetDefaultPrinter strUNCPrinter1

'End the script

Wscript.Quit

 

The above maps the MFD queue for all users, as most users will print to this queue then collect their work from a MFD at a later stage (Pull printing). Therefore, I have a Group Policy object with this script set to run on Logon under 'User configuration', which is applied at the root of our custom 'Computers' OU.

 

In some rooms, there may be a standalone printer. Hence I have another version of the script which maps both the MFD queue and the standalone printer queue :

 

'Name : addprinter.vbs

'Author : Matt Davies

'Date : 22/03/2006

'Description : - Used to add printers for a user

' - Used inconjunction with group policy at Workstation level so it runs per room

' - Needs to be run under "USER" Logon scripts

Option Explicit

Dim objNetwork

'declare the printer names - add as necessary

Dim strUNCPrinter1

Dim strUNCPrinter2

'set the UNC path to the printers you want mapped - add as necessary

strUNCPrinter1 = "\\print\EF17_Infotec"

strUNCPrinter2 = "\\print\MFD_Pull_Queue"

Set objNetwork = CreateObject("WScript.Network")

'remove old printer(s) first

'for debugging comment out next line only

on error resume next

objNetwork.RemovePrinterConnection strUNCPrinter1

objNetwork.RemovePrinterConnection strUNCPrinter2

'Wait 3 seconds whilst windows removes the old printers

wscript.sleep(3000)

'Add the printer to the computer - add as necessary

objNetwork.AddWindowsPrinterConnection strUNCPrinter1

objNetwork.AddWindowsPrinterConnection strUNCPrinter2

' Here is where we set the default printer - change if necessary

objNetwork.SetDefaultPrinter strUNCPrinter1

'End the script

Wscript.Quit

 

This is then applied in the same manner as above to the individual class / staff room sub OUs (located under the main custom Computers OU)

 

It seems to work well and a lot faster than GPP. However, if the user is fast enough they can launch a program such as Word and the script will not have managed to have mapped the required printer as default - Any way to either speed this up or force the user to wait for the script to fully complete before being able to move the mouse / keyboard?

 

Finally I noticed the mapped printers then seem to remain on the user profiles after logging out, so I was thinking I would need a 'Logoff' script to do the opposite of the 'Logon' script - Help!

 

Thanks :)

Posted

There a various printer vbs scripts about then one I use for my xp machine removes all network printers first before deploying them, it loops through all the printers installed and deletes the connections to network printers that way they don't need to be explicitly declared.

 

Ben

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...