Coffeehouse Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Printer Status

Back to Forum: Coffeehouse
  • User profile image

    I am trying to get get the status of a specific printer stored as a variable so something happens when it is printer, or idling, etc. I am able to retrieve the status of all the printer connected to my PC(see code below). How to I set the status of a Pinter as a variable?


    Public Class Form1

        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

            Dim strPrintServer As String, WMIObject As String, PrinterSet As Object, Printer As Object

            strPrintServer = "localhost"
            WMIObject = "winmgmts://" & strPrintServer
            PrinterSet = GetObject(WMIObject).InstancesOf("win32_Printer")

            For Each Printer In PrinterSet
                MsgBox(Printer.Name & ": " & (Printer.PrinterStatus))
            Next Printer
    End Class

  • User profile image

    According to the Win32_Printer WMI documentation, the Status properties are read-only, so no, you cannot set the status of a printer (not that makes much sense in the first place really).

  • User profile image

    I don't think he's trying to set a printer's status because he seems to be wanting to retrieve the status of a specific printer.

    However, I don't understand his question:

    How to I set the status of a Pinter as a variable?

    Are you asking how to make a variable that holds the status of a printer?

    EDIT: Actually, I think you have a printer object stored somewhere and all you're trying to do is update that object with the new status, right? If that's the case...just don't use Win32_Printer. Create your own printer class and update the fields on that.

  • User profile image

    if I read the OP right I think what they want is something  kind of like this:

    ideally to get "printer status events" in their application so that they can then react to changes in the current status of a printer.

    polling wmi with a background worker is one way.....

    I have had mixed results with some of the wmi calls.

    I forget at the moment but some things in WMI are not very good, some are ok but some things are not well implemented.


Conversation locked

This conversation has been locked by the site admins. No new comments can be made.