Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI HELP

Status
Not open for further replies.

ICTECH

Technical User
Joined
Jun 5, 2002
Messages
131
Location
CA
Hi All..

I'm trying to debug an application that ustilizes WMI on a server to get the Printer status. Its works great until the printer is paused then it blows up.. The error is in

If cTmp = "Other" then
tbPrinterError.Text = System.Enum.GetName(GetType(WMI_ExtendedDetectedErrorState), _mo.GetPropertyValue("ExtendedDetectedErrorState"))
Else

It generates "An unhandled exception of typw 'SYstem.Management.ManagemntException' occured in system.management.dll Additional Information: Not Found"

HELP.. Thanks...

 
I would put your syntax in a try catch statement and handle your error that way..

Code:
    If cTmp = "Other" Then
        Try
            tbPrinterError.Text = System.Enum.GetName(GetType(WMI_ExtendedDetectedErrorState), _mo.GetPropertyValue("ExtendedDetectedErrorState"))
        Catch nullRef As NullReferenceException
            'Handle the error here
        End Try
    Else
        'do something else
    End If
 
Hi tEkHEd...

The code is supposted to take the error message and pull up the extended information as to what the error is.. I have a list of Error codes... As follows... But for some reason its not pulling fro this list and I'm at a bit of a loss... Hmmm... It seems to work for all the other Status lookups.. Any ideas?

Public Enum WMI_ExtendedDetectedErrorState As Integer
Unknown = 0
Other = 1
NoError = 2
LowPaper = 3
NoPaper = 4
LowToner = 5
NoToner = 6
DoorOpen = 7
Jam = 8
ServiceRequested = 9
OutputBinFull = 10
PaperProblem = 11
CannotPrintPage = 12
UserInterventionRequired = 13
OutOfMemory = 14
ServerUnknown = 15
End Enum
 
Try this...

Code:
Dim s as string
dim WMIErr as type = GetType(WMI_ExtendedDetectedErrorState)

for each s in [Enum].GetNames(WMI_ExtendedDetectedErrorState)
    console.writeline(s.ToString)
next

this will enumerate the errorstate types in your enum class.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top