http://dieseyer.de • all rights reserved • © 2011 v11.4
'5.A********************************************************
' File: wmi-druckerliste.vbs
' Autor: dieseyer@gmx.de
' dieseyer.de
'
' Listet alle Drucker, die am Computer definiert sind.
'
' Im wesentlichen aus
' http://www.microsoft.com/downloads/details.aspx?FamilyID=b4cb2678-dafb-4e30-b2da-b8814fe2da5a&DisplayLang=en
'************************************************************
Option Explicit ' Siehe http://dieseyer.de/dse-wsh-lernen.html#OptionExpl
Dim strComputer : strComputer = "."
MsgBox DrTest( strComputer ), , "13 :: " & WScript.ScriptName
MsgBox Win32Printer( strComputer ), , "15 :: " & WScript.ScriptName
MsgBox Win32PrinterCfg( strComputer ), , "17 :: " & WScript.ScriptName
WScript.Quit
'************************************************************
Function DrTest( strComputer )
'************************************************************
DrTest = ""
Dim objWMIService, colInstalledPrinters, objPrinter
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
' If InStr( UCase( objPrinter.Name ) , "\\S" ) Then DrTest = DrTest & ">; ; " & objPrinter.Name & vbCRLF
DrTest = DrTest & ">; ; " & objPrinter.Name & vbCRLF
Next
End Function' DrTestTest
'************************************************************
Function Win32Printer( strComputer )
'************************************************************
'On Error Resume Next
Dim objWMIService : Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colItems : Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
Dim objItem
For Each objItem in colItems
If objItem.Default = True Then
Win32Printer = Win32Printer & objItem.Name & vbTab & objItem.Location & vbTab & "Standarddrucker" & vbCRLF
Else
Win32Printer = Win32Printer & objItem.Name & vbTab & objItem.Location & vbCRLF
End If
Next
End Function ' Win32Printer( strComputer )
'************************************************************
Function Win32PrinterCfg( strComputer )
'************************************************************
Dim Tst, Txt
Dim objWMIService : Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colInstalledPrinters : Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_PrinterConfiguration")
Dim objPrinter
For Each objPrinter in colInstalledPrinters
' If InStr( objPrinter.Name, "FinePrint" ) > 0 Then Txt = ""
Tst = Tst & vbCRLF & "Name: " & objPrinter.Name
Tst = Tst & vbCRLF & "Driver Version: " & objPrinter.DriverVersion
Tst = Tst & vbCRLF & "Duplex: " & objPrinter.Duplex
' Tst = Tst & vbCRLF & "Horizontal Resolution: " & objPrinter.HorizontalResolution
If objPrinter.Orientation = 1 Then
Txt = "Portrait"
Else
Txt = "Landscape"
End If
' Tst = Tst & vbCRLF & "Orientation : " & Txt
' Tst = Tst & vbCRLF & "Paper Length: " & objPrinter.PaperLength / 254
' Tst = Tst & vbCRLF & "Paper Width: " & objPrinter.PaperWidth / 254
' Tst = Tst & vbCRLF & "Print Quality: " & objPrinter.PrintQuality
' Tst = Tst & vbCRLF & "Scale: " & objPrinter.Scale
' Tst = Tst & vbCRLF & "Specification Version: " & objPrinter.SpecificationVersion
If objPrinter.TTOption = 1 Then
Txt = "Print TrueType fonts as graphics."
Elseif objPrinter.TTOption = 2 Then
Txt = "Download TrueType fonts as soft fonts."
Else
Txt = "Substitute device fonts for TrueType fonts."
End If
' Tst = Tst & vbCRLF & "True Type Option: " & Txt
Tst = Tst & vbCRLF & "Vertical Resolution: " & objPrinter.VerticalResolution
Tst = Tst & vbCRLF
Next
Win32PrinterCfg = Tst
End Function ' Win32PrinterCfg( strComputer )
http://dieseyer.de • all rights reserved • © 2011 v11.4