WPF set default printer

Posted on 2011-09-26
Last Modified: 2012-05-12
How can I set a specific printer to default printer in WPF?
Question by:VBdotnet2005
  • 2
  • 2

Accepted Solution

anjos earned 125 total points
ID: 36600167
see here:

var query = new ManagementObjectSearcher("SELECT * FROM Win32_Printer"); 
var printers = query.Get();
string printerName = "Printer to set as default" ;
foreach(ManagementObject printer in printers) 
   if (printer["name"].ToString() == printerName.ToString()) 
      printer.InvokeMethod("SetDefaultPrinter", new object[] { printerName }); 

Open in new window


Author Comment

ID: 36600223
I don't see ManagementObjectSearcher after importing
Imports System.Management.Instrumentation
Imports System.Management

Expert Comment

ID: 36600309
and if you try this:

"You will have to rightclick the project -> add reference and add the System.Management assembly"

Author Comment

ID: 36600317
I got it to work now.  Thank you

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Round a string to two digits 12 31
How do I change force the Y axis Maximum in a Visual Studio Chart 5 31
Hide Tab Page 3 34
Help with AsEnumerable(), LINQ 4 22
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now