Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Error getting INF file using WMI commads

Avatar of samelamin
samelamin asked on
Scripting LanguagesMicrosoft Development
8 Comments1 Solution805 ViewsLast Modified:
Hey all

I am trying to retreive the INF file for a installed printer driver

The aim is to uise it to instal clones of the same printer, however I am getting an error and i dont know why because it gives me the name of the printer


the error:
Object reference not set to an instance of an object.
string printerName, printerDriver, portName; bool sharedPrinter;
            string path="not working";
            string infname = "";
            portName = null;

            chosen = comboBox1.SelectedItem.ToString();

            ObjectQuery objectQuery = new ObjectQuery("SELECT * FROM Win32_PrinterDriver WHERE NAME='"+chosen+"'");
            ManagementObjectSearcher searcher =
            new ManagementObjectSearcher(objectQuery);

            foreach (ManagementObject mo in searcher.Get())
           
                {
                    infname = mo["InfName"].ToString();
                }

            MessageBox.Show(infname);
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir RivkinFlag of Israel imageFull stack Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answers