WMI - shared remote printer on remote machine

  • Thread starter Thread starter farshad
  • Start date Start date
F

farshad

The following WMI code only retrieves the list of local shared printers on a
target machine but NOT the list of shared REMOTE printers.
Any suggestions please?
string strWapiServer = "\\\\" + txtServerName.Text;
// Use the ObjectQuery to get the list of configured printers
System.Management.ObjectQuery oquery =
new System.Management.ObjectQuery("SELECT * FROM
Win32_Printer");

ConnectionOptions options = new ConnectionOptions();
ManagementScope myScope = new ManagementScope(strWapiServer +
"\\root\\cimv2", options);

System.Management.ManagementObjectSearcher mosearcher =
new System.Management.ManagementObjectSearcher(myScope,
oquery);

System.Management.ManagementObjectCollection moc =
mosearcher.Get();

foreach (ManagementObject mo in moc)
{
System.Management.PropertyDataCollection pdc = mo.Properties;
cboPrinters.Items.Add(pdc["DeviceID"].Value.ToString());
}
 
Back
Top