Today I had to get the list of printer drivers installed on various servers. I wrote a quick and dirty script to get the printer list.
If you want to use this, copy the following script text and paste it in Notepad. Save it as “PrinterList.vbs”. Run it as,
C:> CSCript PrinterList.vbs <Your Server Name>
‘**************************************************************************
‘ Script Name: PrinterList.vbs
‘ Parameter: Computer Name
‘ Syntax: CScript PrinterList.vbs <Computer Name>
‘
‘ Written By: Anand Venkatachalapathy
‘ http://anandpv.spaces.live.com
‘**************************************************************************
Dim strComputer, i
Dim objWMIService, colInstalledPrinters
‘If there are no arguments pass, quit the script
If WScript.Arguments.Count = 0 Then
WSCript.Echo "No Server/computer name specified…"
WScript.Echo "Syntax: CScript PrinertList.vbs <ComputerName>" & vbCrLf
WSCript.Echo "Example: CScript PrinterList PrintServer1"
WScript.Quit
End If
strComputer = WScript.Arguments(0)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_PrinterDriver")
i = 1
WScript.Echo strComputer & ": Installed Printer Drivers…"
WScript.Echo "———————————————————-"
For each objPrinter in colInstalledPrinters
Wscript.Echo i & ": " & objPrinter.Name
i = i + 1
Next
Set colInstalledPrinters = Nothing
Set objWMIService = Nothing
‘**************************** End of Script ************************
Keywords: List installed printer drivers, List printers, Printer List
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\” & strComputer & “rootcimv2”)
Set colInstalledPrinters = objWMIService.ExecQuery _
(“Select * from Win32_PrinterDriver”)
this script is stuk in this line
Changing it to the following worked for me on windows XP
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)