title: Peeking an MSMQ Outgoing Queue with JScript
body: <p>I created a script to monitor a set of queues, and, while it works perfectly with Remote Private Queues, it doesn't work with Outgoing Queues. I made an experiment by removing everything but the essential from the script, and I created the following test script:</p>
  
  <pre><code>var info = new ActiveXObject("MSMQ.MSMQQueueInfo");
  info.FormatName = /*&lt;Queue name&gt;*/;
  
  // 0x80 = MQ_ADMIN_ACCESS
  // 0x20 = MQ_PEEK_ACCESS
  // 0x00 = MQ_DENY NONE
  var mq = info.Open(0x80 | 0x20, 0x00);
  
  var msg = mq.PeekCurrent(false, true, 0); 
  if (msg != null) {
      WScript.echo("message found");  
  }
  else
  {
      WScript.echo("Nothing");
  }
  mq.close();
  </code></pre>
  
  <p>I then ran it on the server and, even if the queue contains over a thousand messages, <em>PeekCurrent</em> always returns null. If I remove MQ_ADMIN_ACCESS it tries to connect to the Remote Private Queue and it times out (as expected, as it's down to let messages cumulate). If I then start the Remote Private Queue, it reads the message correctly from it.</p>
  
  <p>Out of curiosity, I found out that <em>info.Open</em> always succeeds no matter the Queue Name (i.e. whether it exists or not) when MQ_ADMIN_ACCESS is used. For example, I typed "DIRECT=OS:Whatever\private$\RandomQueueName", and I didn't get any error.</p>
  
  <p>I'm not an expert of MSMQ (quite the opposite), so I'm probably making an obvious mistake and I can't see it. Any help is more than welcome. Thanks.</p>
  
  <p><strong>Side question</strong>: is it possible to peek a Remote Outgoing Queue? At the moment the script is running on the machine where the Outgoing Queue I'm testing is located, but it's not the only one with these queues. I'd like to avoid deploying the script everywhere, I'd prefer to have it in a single place. Thanks.</p>