rckngslnd Posted September 13, 2013 Posted September 13, 2013 Hi Trying to delete all network printers on logoff , but keep getting Access denied error on objPort.Delete_ line, i'm using following script, works fine on admin : 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 Anyone got any ideas, am i right at saying logoff script runs under local admin??
andybarker27 Posted September 13, 2013 Posted September 13, 2013 why not remove them from AD preferences?
round2it Posted September 13, 2013 Posted September 13, 2013 Could i ask why you want to delete the printers. Is it to fix an issue with the spooler or something
rckngslnd Posted September 13, 2013 Author Posted September 13, 2013 Hi The idea of removing the printers is because printers are allocated per OU. When a user moves to another room they will get the printer in that room and the other room, this ok for small sites but we could end up having 40 plus printers and as our users can barely manage to print i would like only the printer allocated to that OU. Also i'm allocated printer via Printer management
RobD Posted November 13, 2013 Posted November 13, 2013 Did you ever find a fix for this?? Having the same issue.
hallb15 Posted November 13, 2013 Posted November 13, 2013 (edited) Try this. On error resume next Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections For i = 0 to oPrinters.Count - 1 Step 2 'WScript.Echo oPrinters.Item(i+1) WshNetwork.RemovePrinterConnection oPrinters.Item(i+1) Edited November 13, 2013 by hallb15
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