Announcement

Collapse
No announcement yet.

WMI remove printer not working?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • WMI remove printer not working?

    Hi Folks

    I have a group of client machines which have a mapped printer from an old server. I have tried to remove this printer using the following wmi script, but for some reason the printer remains - although other printers have been successfully removed using the same script.


    strComputer = "."
    Set objWMIService = GetObject("Winmgmts:\\" & strComputer & "\root\cimv2")
    Set colPrinters = objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

    For Each objPrinter In colPrinters
    objPrinter.Delete_
    Next

    Strangely enough, when I right click this printer on a client machine and select properties, I get the message 'Printer properties cannot be displayed. Either the printer name was typed incorrectly, or the printer has lost it's connection to the server ' even though the server is still there, still serving the printer... for the moment.

    I can delete the printer from the client machines manually, but can anyone suggest a scripting solution to this problem?

    Thanks for reading

  • #2
    Re: VBS script to remove printer not working?

    Hi,

    Just a quick correction about the above.
    It's actually VBS scripting language the one used and no WMI.
    Last edited by L4ndy; 12th June 2009, 09:45.
    Caesar's cipher - 3

    ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

    SFX JNRS FC U6 MNGR

    Comment

    Working...
    X