467,151 Members | 1,115 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,151 developers. It's quick & easy.

List of UNC Paths to networked printers

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.
Expand|Select|Wrap|Line Numbers
  1. private void GetNetworkPrinters()
  2.         {
  3.             try
  4.             {
  5.  
  6.                 string strQuery = "SELECT * FROM Win32_Printer";
  7.  
  8.                 ObjectQuery objectQuery = new ObjectQuery(strQuery);
  9.                 ManagementScope scope = new ManagementScope("\\\\" + EMServer.UserConsole.ApplicationEnvironment.RemoteServerID + "\\root\\cimv2");
  10.                 ManagementObjectSearcher query = new ManagementObjectSearcher(scope, objectQuery);
  11.                 ManagementObjectCollection printers = query.Get();
  12.  
  13.                 foreach (ManagementObject printer in printers)
  14.                 {
  15.                     PropertyDataCollection propertyDataCollection = printer.Properties;
  16.                     this.cboPrinter.Items.Add("\\\\" + printer["Location"] + "\\" + printer["Name"]);
  17.                 }
  18.             }
  19.             catch (Exception ex)
  20.             {
  21.                 MessageBox.Show(ex.Message);
  22.             }
  23.         }
  24.  
Thanks

Drewgy
Mar 2 '09 #1
  • viewed: 1119
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Mike Tammerman | last post: by
reply views Thread by martin | last post: by
reply views Thread by Dexter | last post: by
2 posts views Thread by J | last post: by
4 posts views Thread by Frank Rizzo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.