WSH » wshnetwork » EnumPrinterConnections

Syntax:
WshNetwork.EnumPrinterConnections ()

The EnumPrinterConnections method returns a collection of the current network printer mappings.

The EnumPrinterConnections method returns a WshCollection object that is a collection of the resource names and printer names of all the mapped network printers. All the even-indexed elements in the collection are resource names, while all the odd-indexed elements in the collection are the printer names. Further, the elements are paired (0 and 1 are the first printer, 2 and 3 are the second printer, etc.)

Examples

Code:
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set clPrinters = WshNetwork.EnumPrinterConnections
For i = 0 to clPrinters.Count -1
    WScript.Echo clPrinters.Item(i)
Next
Output:
LPT1:
HP LaserJet 4/4M Plus PS 600
LPT2:
Apple LaserWriter Plus v42.2
FAX:
Canon CFX-L3500 IF
Explanation:

This VBScript code lists all the mapped network printers on a machine.

Language(s): VBScript