• How to check if printer is local or on network

    Posted on January 28, 2013 by in Dotnet Tips & Tricks, Tips & Tricks

    Printer properties can be retrieved using WMI. “Local” property will tell us if it is a network printer or a local printer.

    public static void RetrievePrinterProperties()
    {
        //initialize the select query with command text
        SelectQuery query = new SelectQuery(@"SELECT * FROM Win32_Printer");
    
        //initialize the searcher with the query it is supposed to execute
        using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
        {
            //execute the query
            foreach (ManagementObject process in searcher.Get())
            {
                //print process properties
                Console.WriteLine("/*********Printer Properties ***************/");
                Console.WriteLine("{0}{1}", "Printer Name:", process["Name"]);
                Console.WriteLine("{0}{1}", "Is Printer Offline:", process["WorkOffline"]);
                Console.WriteLine("{0}{1}", "Local Printer:", process["Local"]);
            }
        }
    }
    

    printer is local or on network

    Be Sociable, Share!
      Post Tagged with , ,

    Written by

    View all articles by

    Email : [email protected]

    Leave a Reply