Hi all. I have a very odd problem when printing a test page after installing the printer on the network. That all works very good and when running the code As Administrator... the test page is also printed. But when I run the program "normally" I get an "Access is denied".
So here is the code:
// get the printer
string path = "Win32_Printer.DeviceId='" + printerName + "'";
using (ManagementObject printer = new ManagementObject(path))
{
// invoke the method
object obj = printer.InvokeMethod("PrintTestPage", null);
System.Windows.Forms.MessageBox.Show(obj.ToString());
}
obj is always 5, meaning "Access is denied".
When I invoke the "SetDefaultPrinter" method the same way all is fine for both as administrator and not.
Hopefully anyone has a clue.
Thanks, Simon