Subject: Retrieve printer information within a web service
Posted By: dfitoussi Post Date: 9/18/2003 11:40:26 AM
I'm trying to retrieve the printer information of a computer using WMI and web services. I used this piece of code:

[WebMethod]
public String GetPrinter()
{
  oq = new System.Management.ObjectQuery("SELECT * FROM Win32_PrinterDriver");
  query = new ManagementObjectSearcher(oMs,oq);
  queryCollection = query.Get();
  Console.WriteLine(queryCollection.ToString());
  foreach ( ManagementObject mo in queryCollection)
  {               
    return mo["Caption"].ToString();                    
  }
  return "done";
}

it works fine if i try it in command line but if i call it from a web service the query returns empty. The same piece of code works if i try to retrieve other information (i.e if i replace Win32_Printer by Win32_SoundCard or something else).

Does anybody have an idea of what i'm doing wrong?

Thanks for your help



Go to topic 4219

Return to index page 1043
Return to index page 1042
Return to index page 1041
Return to index page 1040
Return to index page 1039
Return to index page 1038
Return to index page 1037
Return to index page 1036
Return to index page 1035
Return to index page 1034