Can anyone tell me how to get a list of full UNC paths for all printers on a network?
I have tried using WMI but the following code only gives me a list of local printers, and doesn't give me the fully qualified paths.
Thanks
Drewgy
I have tried using WMI but the following code only gives me a list of local printers, and doesn't give me the fully qualified paths.
Code:
private void GetNetworkPrinters()
{
try
{
string strQuery = "SELECT * FROM Win32_Printer";
ObjectQuery objectQuery = new ObjectQuery(strQuery);
ManagementScope scope = new ManagementScope("\\\\" + EMServer.UserConsole.ApplicationEnvironment.RemoteServerID + "\\root\\cimv2");
ManagementObjectSearcher query = new ManagementObjectSearcher(scope, objectQuery);
ManagementObjectCollection printers = query.Get();
foreach (ManagementObject printer in printers)
{
PropertyDataCollection propertyDataCollection = printer.Properties;
this.cboPrinter.Items.Add("\\\\" + printer["Location"] + "\\" + printer["Name"]);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Drewgy