title: How to get System.Printing.PrintServer.GetPrintQueues to return the print queue list from remote server?
body: <h2>Problem</h2>
  
  <p>I'm trying to <strong>get a list of print queues available on a remote server</strong>.  </p>
  
  <p><em>Ultimately this will need to be performed from ASP.NET, but for now I'd settle for a console application to work.</em></p>
  
  <p>When I create an instance of the <strong>System.Printing.PrintServer</strong> class using the path to a remote server I am able to get basic information about the Print Server.  But when I call the <strong>GetPrintQueues method I only get queues that are defined on the local box</strong>.  No matter what I use for the remote device.</p>
  
  <h2>Code</h2>
  
  <pre><code>Imports System.Printing
  
  Module Module1
    Sub Main()
      ListPrintQueues("\\local")
      ListPrintQueues("\\remote")
      ListPrintQueues("\\other")
    End Sub
  
    Sub ListPrintQueues(ByVal server As String)
  
      Dim ps As New PrintServer(server)
      Console.WriteLine("Printer Server=" &amp; ps.Name)
  
      Dim flags() As EnumeratedPrintQueueTypes = {EnumeratedPrintQueueTypes.Connections, EnumeratedPrintQueueTypes.Local}
  
      Dim queues As PrintQueueCollection = ps.GetPrintQueues(flags)
  
      For Each pq As PrintQueue In queues
        Console.WriteLine(pq.FullName)
      Next
  
      Console.WriteLine()
    End Sub
  End Module
  </code></pre>
  
  <h2>Example:</h2>
  
  <p>Assuming the following configuration   </p>
  
  <ul>
  <li>\\local (<em>Local computer with 3 print queues defined, 1 is a remote connection</em>)
  <ul>
  <li>LPrinter1</li>
  <li>LPrinter2</li>
  <li>\\remote\RPrinter1</li>
  </ul></li>
  <li>\\remote (<em>Remote computer with 2 print queues defined</em>)<br>
  <ul>
  <li>RPrinter1</li>
  <li>RPrinter2</li>
  </ul></li>
  <li>\\other (<em>Some other computer with 1 print queue defined</em>)
  <ul>
  <li>OPrinter</li>
  </ul></li>
  </ul>
  
  <p>The results are:</p>
  
  <pre>
  Print Server=\\local  
  \\local\LPrinter1  
  \\local\LPrinter2  
  \\remote\RPrinter1  
  
  Print Server=\\remote  
  \\remote\RPrinter1  
  
  Print Server=\\other
  \\remote\RPrinter1  
  </pre>
  
  <p>My best guess is that something is happening inside the GetPrintQueues() method to cause the print server to be reset to the local box since it doesn't matter what the print server name is as long as it's a valid computer on the network.</p>