System.Management.ManagementException: Not found (Win 2K)

L

lcifers

I have an application that uses the following code to return the
default printer:

Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject


moSearch = New Management.ManagementObjectSearcher("Select *
from Win32_Printer")
moReturn = moSearch.Get

For Each mo In moReturn

If mo("Default") Then
Return mo("Name")
Exit Function
End If

Debug.WriteLine(mo("Name"))



This works fine on my WINXP development machine, but when deployed to a
WIN2K machine, the following error is returned:


************** Exception Text **************
System.Management.ManagementException: Not found

at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus
errorCode)
at System.Management.PropertyData.RefreshPropertyInfo()
at System.Management.PropertyDataCollection.get_Item(String
propertyName)
at System.Management.ManagementBaseObject.GetPropertyValue(String
propertyName)
at System.Management.ManagementBaseObject.get_Item(String
propertyName)
at IMPulseBatchPrintStandAlone.frmMain.IsDefaultPrinter(String
strPrinterName)
at IMPulseBatchPrintStandAlone.frmMain.PrintACADFiles(ArrayList
FileList)
at IMPulseBatchPrintStandAlone.frmMain.cmdPrint_Click(Object sender,
EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)



From NG searches, it looks like perhaps a LOCAL SERVICE account
permissions issue accessing System.Management.dll. On the development
machine it has permissions, but it doesnt even show up in the WIN2K
machine, and I can't find it in the list to add it. Does anyone know
how to fix this?

Thanks.

- Luther
 
H

Herfried K. Wagner [MVP]

lcifers said:
moSearch = New Management.ManagementObjectSearcher("Select *
from Win32_Printer")
moReturn = moSearch.Get

For Each mo In moReturn

If mo("Default") Then
Return mo("Name")
Exit Function
End If

Debug.WriteLine(mo("Name"))

This works fine on my WINXP development machine, but when deployed to a
WIN2K machine, the following error is returned:

************** Exception Text **************
System.Management.ManagementException: Not found

The 'Default' property is not supported on Windows 2000.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top