karldenton Posted February 9, 2009 Posted February 9, 2009 Hi, Just been told we are getting a new photocopier next week. Our current photocopier is networked so people can print to it. Problem we have is that it is in the default profile on the network (created before I started). Without creating a new profile, is there a script that will remove the printer on logon ? Currently using this in one of my scripts but I doesn't seem to get rid of the photocopier? 'objNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True Next 'end delete existing printers Thanks Karl
Michael Posted February 9, 2009 Posted February 9, 2009 This is the trouble with printer scripts. They also puts lots of entries into the registry which can complicate things. I'm not sure of the best route to remove the printer (other than updating the default profile on every machine). You should also consider looking into deploying new printers with group policies.
penfold Posted February 9, 2009 Posted February 9, 2009 Try creating the script and running it locally first. you may find the reason why its not working. And I assume that delete printer line isn't commented out in your script? I have used this(taken from someone here i think) On error resume next 'Remove's All Network Objects (Printers and Drives) Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections For i = 0 to oPrinters.Count - 1 Step 2 WshNetwork.RemovePrinterConnection oPrinters.Item(i+1) Next WScript.Quit To give yourself time to do it, you could add the new printer and make it the default so nobody tries to print to the old one.
karldenton Posted February 9, 2009 Author Posted February 9, 2009 OK. Got a script that does the job great. However, when its done it for one user, if that user logs on again, they get an error message saying itcan't find the printer, which is true. Is there a way to ignore if printer doesn't exist? Option Explicit Dim objNetwork, strUNCPrinter, bForce, bUpdateProfile strUNCPrinter = "\\2003server\Ricoh Aficio 1060 RPCS" bForce = "True" bUpdateProfile = "False" Set objNetwork = CreateObject("WScript.Network") ' Section which removes the network printer objNetwork.RemovePrinterConnection strUNCPrinter, _ bForce, bUpdateProfile WScript.Echo "Check Printers folder NO: " & strUNCPrinter Wscript.Quit Thanks
karldenton Posted February 9, 2009 Author Posted February 9, 2009 Solved it !!! "on error resume next"
gshaw Posted February 9, 2009 Posted February 9, 2009 (edited) This one worked well for me... On error Resume Next Dim objNetwork Dim strUNCPrinter1 strUNCPrinter1 = "\\grs-server\printer" Set objNetwork = CreateObject("WScript.Network") objNetwork.RemovePrinterConnection strUNCPrinter1 Wscript.Quit The first script with the LOOP COUNTER bit looks similar to one we had years ago, never worked properly lol You should also consider looking into deploying new printers with group policies. Unless you like to control your default printers hehe! Edited February 9, 2009 by gshaw
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