Jump to content

Recommended Posts

Posted

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

Posted

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

  • 1 month later...
Posted (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 by hallb15

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