By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,953 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,953 IT Pros & Developers. It's quick & easy.

List of UNC Paths to networked printers

P: 1
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
Share this question for a faster answer!
Share on Google+

Post your reply

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