ozzy Posted February 27, 2009 Posted February 27, 2009 Morning to you all, I use a small .vbs script to map printers on the network and it's been no problem for years. I've just changed a printer in school so altered the script accordingly, the new printer is there but so is the old one!!!! heres the script Set objNetwork = CreateObject("WScript.Network") objNetwork.AddWindowsPrinterConnection "\\europa\itlaser" objNetwork.AddWindowsPrinterConnection "\\europa\xerox" objNetwork.SetDefaultPrinter "\\europa\xerox" The only thing changed was xerox to photocopier. Any Ideas would be welcomed Ozzy:)
mac_shinobi Posted February 27, 2009 Posted February 27, 2009 delete the old one if its not in use and give it the same share name as the old one Short of that you will need to enumerate all printers and remove them all before adding the new ones 1
kmount Posted February 27, 2009 Posted February 27, 2009 Are the old ones removed at any point? (otherwise it will stay ...) 1
ozzy Posted February 27, 2009 Author Posted February 27, 2009 delete the old one if its not in use and give it the same share name as the old one that was what I was going to do and I wish I had:mad:
ozzy Posted February 27, 2009 Author Posted February 27, 2009 Are the old ones removed at any point? (otherwise it will stay ...) Yes the printer was removed, I now have a feeling that it might be in the users profile somewhere.
TheScarfedOne Posted February 27, 2009 Posted February 27, 2009 This lovely bit of scripting below removes all existing network printers (leaves local - eg LPT and USB alone)... we use it to make sure that when users log on, they only get the printers we want them to have. Yes - printer connections do persist in user profile. ' WSH - Windows Logon Script ' Type and Target: Printers Logon Script for Workstations ' Location: King Edward VI Community College ' Compiled: August 2007 ' Author: Stuart Wilkie ' Section 1: Error Handling and Variables ' ==================================================== ' Declare variables and enumerate existing printer connections On Error Resume Next Set WshShell = WScript.CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections Dim computerName computerName = LCase(WshNetwork.ComputerName) ' Delete existing connections to network printers For i = 0 to oPrinters.Count - 1 Step 2 On Error Resume Next if Left(oPrinters.Item(i), 3) <> "lpt" And Left(oPrinters.Item(i), 3) <> "usb" then WshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true else end if Next ' Citrix specific section if (Left(computerName, 5) = "svrts") then computerName = LCase(WshShell.ExpandEnvironmentStrings("%CLIENTNAME%")) end if 3
IrritableTech Posted February 27, 2009 Posted February 27, 2009 The old printer will be in the profile (either roaming or local cache) I found a bit of vbs yesterday that deletes all network printers which you can run before adding. 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 No written by me but publically available for free on the internet. [edit]Oh I was beaten to it! 1
TheScarfedOne Posted February 27, 2009 Posted February 27, 2009 LOL - you can tell what time we all got to work today!! Logon - Edugeek, check posts! :-)
itwasntme Posted February 27, 2009 Posted February 27, 2009 (edited) RUP's drag all of the printers you've added as that user everywhere. See here; How to Alter Behavior of Printers That Roam with Roaming Profiles I realise that 2k3 R2 has added some printer support, which is great, however we had already done this with vbs at login. We clear all non-local printers at user login, if the user is a member of staff they have a text file in their user area containing names of printers to be added (added via an HTA script they have access to), after this, regardless of staff/student, room/location specific printers are added via a csv file. There was some initial confusion but when they realised the benefits they were more than happy with the solution. edit;Aww man, so many replies before I got a chance to finish my reply... I blame this shocking internet connection! Edited February 27, 2009 by itwasntme aww
ozzy Posted February 27, 2009 Author Posted February 27, 2009 "LOL - you can tell what time we all got to work today!! Logon - Edugeek, check posts! :-) Sad eh;)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now