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)
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
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)
permissions issue accessing System.Management.dll. On the developmentFrom NG searches, it looks like perhaps a LOCAL SERVICE account
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