+ Post New Thread
Results 1 to 6 of 6
Windows 7 Thread, Removing network printers in Technical; Hi Trying to delete all network printers on logoff , but keep getting Access denied error on objPort.Delete_ line, i'm ...
  1. #1
    rckngslnd's Avatar
    Join Date
    Nov 2010
    Location
    Margate
    Posts
    47
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Removing network printers

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

  2. #2

    Join Date
    Jul 2013
    Location
    Yeadon, Leeds
    Posts
    43
    Thank Post
    5
    Thanked 1 Time in 1 Post
    Rep Power
    0
    why not remove them from AD preferences?

  3. #3
    round2it's Avatar
    Join Date
    May 2009
    Location
    UK
    Posts
    999
    Thank Post
    198
    Thanked 144 Times in 102 Posts
    Rep Power
    36
    Could i ask why you want to delete the printers.

    Is it to fix an issue with the spooler or something

  4. #4
    rckngslnd's Avatar
    Join Date
    Nov 2010
    Location
    Margate
    Posts
    47
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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

  5. #5
    RobD's Avatar
    Join Date
    Mar 2007
    Posts
    109
    Thank Post
    0
    Thanked 8 Times in 8 Posts
    Rep Power
    17
    Did you ever find a fix for this?? Having the same issue.

  6. #6
    hallb15's Avatar
    Join Date
    Jan 2012
    Location
    Leeds
    Posts
    405
    Thank Post
    462
    Thanked 231 Times in 149 Posts
    Rep Power
    74
    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)
    Last edited by hallb15; 13th November 2013 at 02:53 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 3
    Last Post: 14th December 2011, 03:31 PM
  2. Removing Network Printer
    By Little-Miss in forum Windows Server 2000/2003
    Replies: 11
    Last Post: 13th October 2010, 02:26 PM
  3. Recommend a cheap network printer
    By Kyle in forum Hardware
    Replies: 15
    Last Post: 14th June 2006, 04:42 PM
  4. Change network printer default setting
    By speckytecky in forum Wireless Networks
    Replies: 1
    Last Post: 31st May 2006, 06:44 PM
  5. Replies: 7
    Last Post: 27th November 2005, 10:41 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •