Jump to content

Printer Data


Recommended Posts

Does anyone know where in the Registry I can find the data for installed and networked printers? I have a script that will read the registry for the networked printers but it only gives me the Server and Printer Name. I am looking to find the Printer Make and Model. If you check the Printer properties it will show so that tells me it has to be stored somewhere, I just need to know where so I can direct the script to it if possible. Also bare with me as I am new to this scripting stuff. I appreciate any wisdom that anyone can share with me. Thank you for your time.
Link to comment
Share on other sites

Might have to pare this down a tad:

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "Attributes: " & $objItem.Attributes & @CRLF
      $Output = $Output & "Availability: " & $objItem.Availability & @CRLF
      $strAvailableJobSheets = $objItem.AvailableJobSheets(0)
      $Output = $Output & "AvailableJobSheets: " & $strAvailableJobSheets & @CRLF
      $Output = $Output & "AveragePagesPerMinute: " & $objItem.AveragePagesPerMinute & @CRLF
      $strCapabilities = $objItem.Capabilities(0)
      $Output = $Output & "Capabilities: " & $strCapabilities & @CRLF
      $strCapabilityDescriptions = $objItem.CapabilityDescriptions(0)
      $Output = $Output & "CapabilityDescriptions: " & $strCapabilityDescriptions & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $strCharSetsSupported = $objItem.CharSetsSupported(0)
      $Output = $Output & "CharSetsSupported: " & $strCharSetsSupported & @CRLF
      $Output = $Output & "Comment: " & $objItem.Comment & @CRLF
      $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
      $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
      $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $strCurrentCapabilities = $objItem.CurrentCapabilities(0)
      $Output = $Output & "CurrentCapabilities: " & $strCurrentCapabilities & @CRLF
      $Output = $Output & "CurrentCharSet: " & $objItem.CurrentCharSet & @CRLF
      $Output = $Output & "CurrentLanguage: " & $objItem.CurrentLanguage & @CRLF
      $Output = $Output & "CurrentMimeType: " & $objItem.CurrentMimeType & @CRLF
      $Output = $Output & "CurrentNaturalLanguage: " & $objItem.CurrentNaturalLanguage & @CRLF
      $Output = $Output & "CurrentPaperType: " & $objItem.CurrentPaperType & @CRLF
      $Output = $Output & "Default: " & $objItem.Default & @CRLF
      $strDefaultCapabilities = $objItem.DefaultCapabilities(0)
      $Output = $Output & "DefaultCapabilities: " & $strDefaultCapabilities & @CRLF
      $Output = $Output & "DefaultCopies: " & $objItem.DefaultCopies & @CRLF
      $Output = $Output & "DefaultLanguage: " & $objItem.DefaultLanguage & @CRLF
      $Output = $Output & "DefaultMimeType: " & $objItem.DefaultMimeType & @CRLF
      $Output = $Output & "DefaultNumberUp: " & $objItem.DefaultNumberUp & @CRLF
      $Output = $Output & "DefaultPaperType: " & $objItem.DefaultPaperType & @CRLF
      $Output = $Output & "DefaultPriority: " & $objItem.DefaultPriority & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "DetectedErrorState: " & $objItem.DetectedErrorState & @CRLF
      $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF
      $Output = $Output & "Direct: " & $objItem.Direct & @CRLF
      $Output = $Output & "DoCompleteFirst: " & $objItem.DoCompleteFirst & @CRLF
      $Output = $Output & "DriverName: " & $objItem.DriverName & @CRLF
      $Output = $Output & "EnableBIDI: " & $objItem.EnableBIDI & @CRLF
      $Output = $Output & "EnableDevQueryPrint: " & $objItem.EnableDevQueryPrint & @CRLF
      $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
      $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
      $strErrorInformation = $objItem.ErrorInformation(0)
      $Output = $Output & "ErrorInformation: " & $strErrorInformation & @CRLF
      $Output = $Output & "ExtendedDetectedErrorState: " & $objItem.ExtendedDetectedErrorState & @CRLF
      $Output = $Output & "ExtendedPrinterStatus: " & $objItem.ExtendedPrinterStatus & @CRLF
      $Output = $Output & "Hidden: " & $objItem.Hidden & @CRLF
      $Output = $Output & "HorizontalResolution: " & $objItem.HorizontalResolution & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "JobCountSinceLastReset: " & $objItem.JobCountSinceLastReset & @CRLF
      $Output = $Output & "KeepPrintedJobs: " & $objItem.KeepPrintedJobs & @CRLF
      $strLanguagesSupported = $objItem.LanguagesSupported(0)
      $Output = $Output & "LanguagesSupported: " & $strLanguagesSupported & @CRLF
      $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
      $Output = $Output & "Local: " & $objItem.Local & @CRLF
      $Output = $Output & "Location: " & $objItem.Location & @CRLF
      $Output = $Output & "MarkingTechnology: " & $objItem.MarkingTechnology & @CRLF
      $Output = $Output & "MaxCopies: " & $objItem.MaxCopies & @CRLF
      $Output = $Output & "MaxNumberUp: " & $objItem.MaxNumberUp & @CRLF
      $Output = $Output & "MaxSizeSupported: " & $objItem.MaxSizeSupported & @CRLF
      $strMimeTypesSupported = $objItem.MimeTypesSupported(0)
      $Output = $Output & "MimeTypesSupported: " & $strMimeTypesSupported & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $strNaturalLanguagesSupported = $objItem.NaturalLanguagesSupported(0)
      $Output = $Output & "NaturalLanguagesSupported: " & $strNaturalLanguagesSupported & @CRLF
      $Output = $Output & "Network: " & $objItem.Network & @CRLF
      $strPaperSizesSupported = $objItem.PaperSizesSupported(0)
      $Output = $Output & "PaperSizesSupported: " & $strPaperSizesSupported & @CRLF
      $strPaperTypesAvailable = $objItem.PaperTypesAvailable(0)
      $Output = $Output & "PaperTypesAvailable: " & $strPaperTypesAvailable & @CRLF
      $Output = $Output & "Parameters: " & $objItem.Parameters & @CRLF
      $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
      $Output = $Output & "PortName: " & $objItem.PortName & @CRLF
      $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
      $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
      $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
      $strPrinterPaperNames = $objItem.PrinterPaperNames(0)
      $Output = $Output & "PrinterPaperNames: " & $strPrinterPaperNames & @CRLF
      $Output = $Output & "PrinterState: " & $objItem.PrinterState & @CRLF
      $Output = $Output & "PrinterStatus: " & $objItem.PrinterStatus & @CRLF
      $Output = $Output & "PrintJobDataType: " & $objItem.PrintJobDataType & @CRLF
      $Output = $Output & "PrintProcessor: " & $objItem.PrintProcessor & @CRLF
      $Output = $Output & "Priority: " & $objItem.Priority & @CRLF
      $Output = $Output & "Published: " & $objItem.Published & @CRLF
      $Output = $Output & "Queued: " & $objItem.Queued & @CRLF
      $Output = $Output & "RawOnly: " & $objItem.RawOnly & @CRLF
      $Output = $Output & "SeparatorFile: " & $objItem.SeparatorFile & @CRLF
      $Output = $Output & "ServerName: " & $objItem.ServerName & @CRLF
      $Output = $Output & "Shared: " & $objItem.Shared & @CRLF
      $Output = $Output & "ShareName: " & $objItem.ShareName & @CRLF
      $Output = $Output & "SpoolEnabled: " & $objItem.SpoolEnabled & @CRLF
      $Output = $Output & "StartTime: " & WMIDateStringToDate($objItem.StartTime) & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF
      $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
      $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF
      $Output = $Output & "TimeOfLastReset: " & WMIDateStringToDate($objItem.TimeOfLastReset) & @CRLF
      $Output = $Output & "UntilTime: " & WMIDateStringToDate($objItem.UntilTime) & @CRLF
      $Output = $Output & "VerticalResolution: " & $objItem.VerticalResolution & @CRLF
      $Output = $Output & "WorkOffline: " & $objItem.WorkOffline & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Printer" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...