Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:31:03+00:00 2026-06-14T03:31:03+00:00

I’ve been trying to find a way to figure out which installed printers are

  • 0

I’ve been trying to find a way to figure out which installed printers are ‘connected’. After some Googling I figured I had to dive into WMI.

So I’ve built this test:

// Struct to store printer data in.
public struct MyPrinter 
{ 
    public string Availability; 
    public string ExtendedPrinterStatus; 
    public string Name; 
    public string PrinterStatus; 
    public string Status; 
    public string StatusInfo; 

    public MyPrinter(string a, string eps, string n, string ps, string s, string si) 
    { 
        Availability = a; 
        ExtendedPrinterStatus = eps; 
        Name = n; 
        PrinterStatus = ps; 
        Status = s; 
        StatusInfo = si; 
    } 
}


var installedPrinters = new string[numPrinters];
PrinterSettings.InstalledPrinters.CopyTo(installedPrinters, 0);

var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer"); 
var data = new List<MyPrinter>(); 

foreach (var printer in searcher.Get()) 
{ 
    if (installedPrinters.Contains(printer["Name"].ToString()))
    {
        var availability = (printer["Availability"] ?? "").ToString(); 
        var extendedPrinterStatus = (printer["ExtendedPrinterStatus"] ?? "").ToString(); 
        var name = (printer["Name"] ?? "").ToString(); 
        var printerStatus = (printer["PrinterStatus"] ?? "").ToString(); 
        var status = (printer["Status"] ?? "").ToString(); 
        var statusInfo = (printer["StatusInfo"] ?? "").ToString(); 

        data.Add(new MyPrinter(availability, extendedPrinterStatus, name, printerStatus, status, statusInfo)); 
    }
}

I have 6 printers from which 2 are network printers. I’ve run this with all printers connected and all results looked like this:

Availability = "" // printer["Availability"] = null
ExtendedPrinterStatus = "2" // 2 = Unknown
Name = "{printer name here}"
PrinterStatus = "3" // 3 = Idle
Status = "Unknown"
StatusInfo = "" // Null

So the only difference between the printers is the name.
I ran the script again but this time I disconnected my laptop from the network. So 2 of the printers were not connected anymore in this case.

The strange thing (for me) is, the results were exactly the same.

The reason I ran this test is, to figure out which field I’d need to use for my case.

So at the end, I have not been able to figure out how to figure out if a printer is connected or not.
So what I’d like, is a way to figure out the installed + connected printers in C#. If there is a way to do it without the use of WMI classes, that’s also fine by me, as long as it works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:31:04+00:00Added an answer on June 14, 2026 at 3:31 am

    Me and a colleague have tried lots of stuff to find a solution for this and we figured this worked:

    private string[] GetAvailablePrinters()
    {
        var installedPrinters = new string[PrinterSettings.InstalledPrinters.Count];
        PrinterSettings.InstalledPrinters.CopyTo(installedPrinters, 0);
    
        var printers = new List<string>();
        var printServers = new List<string>();
        var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
    
        foreach (var printer in searcher.Get())
        {
            var serverName = @"\\" + printer["SystemName"].ToString().TrimStart('\\');
            if (!printServers.Contains(serverName))
                printServers.Add(serverName);
        }
    
        foreach (var printServer in printServers)
        {
            var server = new PrintServer(printServer);
            try
            {
                var queues = server.GetPrintQueues();
                printers.AddRange(queues.Select(q => q.Name));
            }
            catch (Exception)
            {
                // Handle exception correctly
            }
        }
    
        return printers.ToArray();
    }
    

    The trick is that when a printserver is not available, GetPrintQueues will throw some specific exception. By only adding the printers that don’t throw such an exception, we get a list of all the connected printers. This doesn’t check if a printer is turned on/off because that actually doesn’t matter. If it is turned off, the document will just be placed in the print queue and it can be printed later on.

    I hope this helps others who bump into this problem.

    Sidenote:
    The reason I decided not to catch that specific exception, is because I would have to reference a dll just for that exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to select an H1 element which is the second-child in its group
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have been unable to fix a problem with Java Unicode and encoding. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.