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.ThrowWithExt endedInfo(ManagementStatus
errorCode)
at System.Management.PropertyData.RefreshPropertyInfo ()
at System.Management.PropertyDataCollection.get_Item( String
propertyName)
at System.Management.ManagementBaseObject.GetProperty Value(String
propertyName)
at System.Management.ManagementBaseObject.get_Item(St ring
propertyName)
at IMPulseBatchPrintStandAlone.frmMain.IsDefaultPrint er(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(MouseEventAr gs 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(M essage& 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