VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



WMI sample: retrieves printer status on local or remote computer. Written in VBScript. Uses win32_P

by Anonymous (267 Submissions)
Category: Windows System Services
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th May 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

WMI sample: retrieves printer status on local or remote computer. Written in VBScript. Uses win32_Printer WMI class.

Rate WMI sample: retrieves printer status on local or remote computer. Written in VBScript. Uses win32_P



' This function checks if a printer is up-and-running
' Requires WMI

' Check out http://www.activexperts.com for more samples and components


Const PrinterIdle = 3
Const PrinterPrinting = 4
Const PrinterWarmingUp = 5

Function IsPrinterUp( strPrintServer, strPrinter )
    Dim strobject, PrinterSet, Printer

    IsPrinterUp = False

    strObject = "winmgmts://" & strPrintServer
    Set PrinterSet = GetObject( strObject ).InstancesOf( "win32_Printer" )
    If( PrinterSet.Count = 0 ) Then 
        Exit Function
    End If

    For Each Printer in PrinterSet 
        WScript.Echo Printer.Name & " ==> " & Printer.PrinterStatus 
        If UCase( Printer.name ) = UCase( strPrinter  ) Then
       If Printer.PrinterStatus = PrinterIdle Or Printer.PrinterStatus = PrinterPrinting Or Printer.PrinterStatus = PrinterWarmingUp Then
                IsPrinterUp = True
                Exit Function
           End If 
        End If           
    Next

End Function



' Main

Dim strPrintServer, strPrinterName
Do
   strPrinterName = inputbox( "Please enter the name of the printer", "Input" )
Loop until strPrinterName <> ""
Do
   strPrintServer = inputbox( "Please enter the name of the printserver", "Input" )
Loop until strPrintServer <> ""
If( IsPrinterUp( strPrintServer, strPrinterName ) = True ) Then
    WScript.Echo "Printer " & strPrinterName & " is OK"
Else
    WScript.Echo "Printer " & strPrinterName & " is NOT OK"
End If

Download this snippet    Add to My Saved Code

WMI sample: retrieves printer status on local or remote computer. Written in VBScript. Uses win32_P Comments

No comments have been posted about WMI sample: retrieves printer status on local or remote computer. Written in VBScript. Uses win32_P. Why not be the first to post a comment about WMI sample: retrieves printer status on local or remote computer. Written in VBScript. Uses win32_P.

Post your comment

Subject:
Message:
0/1000 characters