Jump to content

Recommended Posts

Posted

Up until now to map network printers I've been using vbs login scripts mixed with GPO loopback functionality based on OU location but ideally want to use the Print Management console included in Win 2k3 R2 which uses pushprinterconnection.exe to deploy on a per computer level.

 

The way this is meant to work as I understand it is that if a computer is moved out of the applying OU, the pushprinterconnection.exe should remove the mapping. The problem I'm having is that when the computer is removed from the OU the printer mapping still remains even after multiple boots, forced group policy update and even manual deletion.

 

Googling this, it seems that this may be a bug when using this on a per-computer configuration and some mention that the mapping gets tattooed onto the users registry which is why this still appears even after manual deletion.

 

Has anyone else had any joy with this or found a workaround?

Posted

We are getting exactly the same thing on Server 2008 R2. Printers are deployed using Print Management but they roam with the user so when they next log on the previous printer appears as well as the current one! this can get annoying if teachers use multiple PCs as they start to collect them and end up with 10 printers on some occasions!

 

Not found a workaround as yet, but it's doing my head in!

Posted
Went with my own mix of logon/logoff vbs scripts in the end which work just as well. Shame though as wanted a central management for this.
Posted

Could i be cheeky, and possibly ask you to post one of your logon / logoff scripts for this purpose?

 

It would be interesting to know what commands are run at which stage.

Posted
We are getting exactly the same thing on Server 2008 R2. Printers are deployed using Print Management but they roam with the user so when they next log on the previous printer appears as well as the current one! this can get annoying if teachers use multiple PCs as they start to collect them and end up with 10 printers on some occasions!

 

Not found a workaround as yet, but it's doing my head in!

 

If you have 2008R2 DCs then don't use the Print Management console, use Group Policy Preferences instead. You get much more control over how printers apply and can set deletes/replace on each preference item to ensure printers don't build up.

Posted

I use loopback and Logon for printers .. What type of profiles are you using ? I use the following script which works good ;) ..

 

'VBScript.' Updated June 2009 Luke Taylor

'Purpose of script is to remove and add multiple network printers And Set the Time

'***************************************************************************

 

ON ERROR RESUME NEXT

 

Set WshNetwork = WScript.CreateObject("WScript.Network")

 

'Remove old printers

WshNetwork.RemovePrinterConnection "\\server\BWLaser", True, True

 

'Install new Printers

WshNetwork.AddWindowsPrinterConnection "\\server\BWLaser"

 

'set default Printer

WshNetwork.SetDefaultPrinter "\\server\BWLaser"

 

'Clean Up Memory Used

Set WshNetwork = Nothing

 

wscript.quit

 

 

have a try of that and see if it fixes your problem ? its a logon script btw .. If it does not work like this , try adding every printer you have into the remove old printers section .

Posted (edited)

Currently I use Two logon scripts. One to remove all existing network printers

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

 

Set colInstalledPrinters = objWMIService.ExecQuery _

("Select * from Win32_Printer Where Network = TRUE")

 

For Each objPrinter in colInstalledPrinters

objPrinter.Delete_

Next

 

And another to add the required printer

' Map Printer

' ******************************

Option Explicit

Dim netPrinter, UNCpath

UNCpath = "\\server\printer"

Set netPrinter = CreateObject("WScript.Network")

netPrinter.AddWindowsPrinterConnection UNCpath

WScript.Quit

 

I want to merge these together similar to the above script but for testing purposes was ideal at the time to be separate.

Edited by randle
Posted
We use con2prt.exe to set printers on each PC. A batch file runs at logon to pick up some Environment Variables to set default and other printers dynamically.
  • 2 weeks later...
Posted (edited)

If you have that problem you might want to look at the local machine policy in the registry under the system / currentcontrol set 001 , 002 , 003 / connections. You will find those little nasty's hidden there!

 

I wrote a script that removes those old connection keys when the PC has changed OU.

 

you could add something like this to the computer startup in a batch file:

 

reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Connections\,,myprintserver,oldprinter-bw" /f

reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Control\Print\Connections\,,myprintserver,oldprinter-bw" /f

Edited by MaXiM
Posted
The first script I use above removes the stuck printers from the registry location you mention and appears to work nicely with a mix of GPO loopback
  • 3 months later...
Posted
If you have 2008R2 DCs then don't use the Print Management console, use Group Policy Preferences instead. You get much more control over how printers apply and can set deletes/replace on each preference item to ensure printers don't build up.

 

Have been trying to deploy printers for W7 with GPP, for students using roaming profiles. GPP prefs don't delete the queues either when out of scope of AD container or item level targetting. Also tried deployed printers option, but again queues are'nt removed when out of scope, currently trying to find logoff script to delete queues. Which method do you use, can you help.? Thank you.

Posted

Print Management console works fine if you remember to remove the printers using the console when they fall out of scope. Then you will not get those left overs.. If you get the left overs because you forgot to remove the printers using the console then the script i posted does that.

 

As far as windows 7 goes you can still use the print management console or in some places I have worked I used con2prt.exe in the user login script to map the printers during login, that seems to work well also.

Posted

Example .vbs script to delete network printers on logoff

 

On Error Resume Next

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

 

Set colInstalledPrinters = objWMIService.ExecQuery _

("Select * from Win32_Printer Where Network = TRUE")

 

For Each objPrinter in colInstalledPrinters

objPrinter.Delete_

Next

Posted

Example .vbs script on computer startup that removes annoying printers that like to default themselves.

Only use this if you don't want those printers

 

 

On Error resume next

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

 

Set colInstalledPrinters = objWMIService.ExecQuery _

("Select * from Win32_Printer where DeviceID = 'Send To OneNote 2007'")

For Each objPrinter in colInstalledPrinters

objPrinter.Delete_

Next

 

Set colInstalledPrinters = objWMIService.ExecQuery _

("Select * from Win32_Printer where DeviceID = 'Microsoft XPS Document Writer'")

For Each objPrinter in colInstalledPrinters

objPrinter.Delete_

Next

 

Set colInstalledPrinters = objWMIService.ExecQuery _

("Select * from Win32_Printer where DeviceID = 'Microsoft Office Document Image Writer'")

For Each objPrinter in colInstalledPrinters

objPrinter.Delete_

Next

 

 

 

wscript.quit

Posted (edited)

Example Con2prt.exe that can be added to user logon script using GP or local GPedit

Obviously you need to download con2prt.exe from somewhere in the first place

 

@echo off

 

start "\\mydomain.local\NETLOGON\PrinterScripts\con2prt.exe /c" "\\myprintserver\Staff Room Colour Laser"

 

start "\\mydomain.local\NETLOGON\PrinterScripts\con2prt.exe /cd" "\\myprintserver\Staff Room Mono Laser"

 

 

Exit

Edited by MaXiM
Posted

This script .vbs is very nifty... but doesn't really like W7 PC's because of the UAC.. but with XP it's a beauty.

Firstly you create the script like below. As you will notice it refers to a txt file which I will show you in the next post

 

 

'Dimming Variables

 

dim comname

dim printerpath

dim fileexist

dim listline

dim list

dim counter

dim intval 'General Storage for temp values

'__________________________________________________________

 

'Creating Objects

set fileaccess=createobject("Scripting.filesystemobject")

set networkaccess=createobject("Wscript.network")

'__________________________________________________________

 

 

 

'Check existence of the list file

fileexist=fileaccess.fileexists("\\myserver\netlogon\list.txt")

 

if fileexist="False" then

msgbox "Connection List is not available! Printer connection abort.",,"Printer Connection abort"

else

'open list

set list = fileaccess.OpenTextFile ("\\myserver\netlogon\list.txt")

readlines

end if

 

function readlines()

do until list.atendofstream

listline=list.readline

intval=0

for counter=1 to len(listline)

if mid(listline,counter,1)=":" then

intval=intval+1

end if

next

if intval=1 then

 

comname=""

printerpath=""

intval = 0

for counter=1 to len(listline)

if mid(listline,counter,1) = ":" then

intval=1

counter=counter+1

end if

if intval=0 then

comname=comname & mid(listline,counter,1)

end if

if intval=1 then

printerpath=printerpath & mid(listline,counter,1)

end if

next

 

 

if mid(comname,len(comname),1)="*" then

 

comname=mid(comname,1,len(comname)-1)

comname=ucase(Comname)

 

if mid(networkaccess.computername,1,len(comname))=comname then

 

on error resume next

networkaccess.AddWindowsprinterconnection printerpath

end if

else

 

if networkaccess.computername = comname then

on error resume next

networkaccess.AddWindowsprinterconnection printerpath

end if

 

end if

else

 

end if

loop

 

end function

function exitpro()

msgbox "Printer: " & printerpath & " is not available, please check the path in the connection list or hardware status of the printer.",,"Printer connection fail"

end function

Posted

In the .txt file you specify the computer names or the beggining of the computer names followed by a star if you want all computers beginning with the same name to have the printers applied.

 

So if you had a room of computers called for example : ART01,ART02,ART03 etc... To apply the printers you would simply put Art* and that would apply the required printers to all the Art computers. Hope that makes sense.

 

Art*:\\myprintserver\Design Colour Laser

Art*:\\myprintserver\Textiles Colour Laser

biology*:\\myprintserver\Design Mono Laser

bio*:\\myprintserver\Design Colour Laser

bio*:\\myprintserver\Design Mono Laser

chemistry*:\\myprintserver\Design Mono Laser

chemistry*:\\myprintserver\Design Colour Laser

eng*:\\myprintserver\Gallery Mono Laser

eng*:\\myprintserver\Gallery Colour Laser

eng*\\englishsb\English Mono Laser

exam*:\\myprintserver\ICT1 Mono Laser

drama*:\\myprintserver\Music Mono Laser

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...