Get Printdriver information with System.Printing classes

362 views Asked by At

I try to get information about several printers in our network. Because WMI isn't allowed on our server I try to get the same information I would get with the Win32_PrinterDriver WMI-class e.g. ConfigFile, DataFile, DependentFiles, DriverPath and so on (at best all properties I can get via WMI).

PrintServer ps = new PrintServer(serverName);
PrintQueueCollection printQueueCollection = ps.GetPrintQueues();

foreach (PrintQueue pq in printQueueCollection)
{
    foreach (DictionaryEntry prop in  pq.QueueDriver.PropertiesCollection)
    {
        // add props to Dictionary/Print out or sth else
    }
...

However the Collection I get with pq.QueueDriver.PropertiesCollection has only the Name property. I've tried that on 119 different PrintQueues for now.

Is there a reason why I just get the name? Or am I using the wrong class here?

1

There are 1 answers

2
d.moncada On

You can get the informatin using the built in Windows VB scripts provided by the OS. The location of them are here:

C:\Windows\System32\Printing_Admin_Scripts\en-US

You can call it using the method described in this post: call VB script in c# and then pipeout the information to an event handler, and grab it from there.

More info about the built in VB print scripts and what they do can be found here.