CJ

The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

Display all network printers

Posted by Clayton James on November 27, 2008

 

 

 

 

 

 

 

 

 

 

A post that I know I will need again.

string

strServer = \\\\printservername;

//if the computer is local machine, use the “.” instead
ConnectionOptions options = new ConnectionOptions();
options.Username =
“username”;
options.Password =
“pswd”;
options.Authority =
“NTLMDOMAIN:domain”; 

 

ManagementScope myScope = new ManagementScope(strServer + \\root\\cimv2, options);
SelectQuery oQuery = new SelectQuery(“SELECT * FROM WIN32_Printer”);
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);

//Iterate through printers…
foreach (ManagementObject oItem in oResults.Get())
{
     string strPrinterName = oItem.Properties[“DeviceID”].Value.ToString();
|

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: