Retrieve printer information within a web service
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
|