Remove all network printers by VBS

article #1024, updated 2839 days ago

This works well:

Option Explicit
Dim strComputer

strComputer = "."

Dim objWMI,networkPrinters,networkPrinter
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set networkPrinters = objWMI.ExecQuery("Select * From Win32_Printer Where Network = true") 

For Each networkPrinter in networkPrinters 
    networkPrinter.Delete_ 
Next 

Set networkPrinter = Nothing
Set networkPrinters = Nothing
Set objWMI = Nothing

Categories: