Check Printer Status(online/offline)

Hi,

Below code is use to check if our Printer in connected or not connected ie. online or offline.


' Set management scope
Dim scope As New ManagementScope("\root\cimv2")
scope.Connect()
' Select Printers from WMI Object Collections
Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_Printer")
Dim printerName As String = ""
For Each printer As ManagementObject In searcher.[Get]()
printerName = printer("Name").ToString().ToLower()

If printerName.Equals("evolis pebble") Then
Console.WriteLine("Printer = " + printer("Name"))
If printer("WorkOffline").ToString().ToLower().Equals("true") Then
' printer is offline by user
Console.WriteLine("Your Plug-N-Play printer is not connected.")
MsgBox("Your Plug-N-Play printer is not connected.")
Else
' printer is not offline
Console.WriteLine("Your Plug-N-Play printer is connected.")
MsgBox("Your Plug-N-Play printer is connected.")
MsgBox("Printer = " + printer("Name"))
End If
End If
Next


It is so usefull to check printer before printer.


Comments



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: