VbScript MSMQManagement - get message count

Go To StackoverFlow.com

1

Can anyone help me with the question. I'm trying to get msmq messages count with vbscript.

Dim MSMQApp 
Set MSMQApp = CreateObject("MSMQ.MSMQApplication")

Dim qFormat 
For each qFormat in MSMQApp.PrivateQueues
   WScript.Echo qFormat
   Dim Mgmt 
   Set Mgmt = CreateObject("MSMQ.MSMQManagement")
   Mgmt.Init ,,"DIRECT=OS:" & qFormat
   WScript.Echo CLng(Mgmt.MessageCount)
Next

There is a private queue - I see in WScript.Echo qFormat. But when Init I have an error: The queue is not open or may not exist.

Help me, please.

2012-04-05 15:07
by Elena


2

The problem was - "An exception is thrown and a nonspecific MQ_ERROR (0xC00E0001) error is generated if the destination or outgoing queue specified does not contain any messages and no handle to it exists." There is queue, but there is no messages in it - exception.

2012-04-06 15:10
by Elena
Yes, if there are no messages in the queue or no application is using the queue then it does not exist as a data structure you can analyse. This is to conserve resources - John Breakwell 2012-04-08 21:02
Ads