Delete all private queues in MSMQ?

2

1

Is there any way in MSMQ to delete all private queues?

I have thousands of private queues on my computer, I'm fairly sure most, if not all, of them, are caused by a badly behaved app that creates a new queue with a random GUID for its name every time it starts up.

Now I want to create a couple of other private queues to do some work with MSMQ, I'm finding that the thousands of unused existing queues are not only cluttering up the view when I open Private Queues in the Computer Management tool, but I suspect they are the reason why opening Private Queues in Computer Management takes ages on my machine.

I can delete individual queues by just selecting one and hitting delete, but there doesn't seem to be an obvious way of selecting a range of queues to delete together.

PhantomDrummer

Posted 2012-02-29T11:27:00.903

Reputation: 719

Answers

0

I'm not sure of the version of Windows you're using but I'm assuming you have MSMQ 3.0 installed. That being the case, you can query all your private MSMQ objects using VBS and calling the Private Queues property in the MSMQ Application Object and storing them as a Variant.

Then, I would cycle through your Variant and use the Delete property of MSMQQueueInfo and delete each queue.

Hope that helps.

Carlos

Posted 2012-02-29T11:27:00.903

Reputation: 799

OK, thanks. I was hoping there'd be some way to avoid writing a script to delete them, but I guess script it'll have to be.... – PhantomDrummer – 2012-03-06T14:38:45.880

Ah, don't sweat it. I'm sure you can whip something up in mere minutes. – Carlos – 2012-03-06T15:47:16.587

0

You can also write a small program by using code below.

Note that your project should reference System.Messaging

using System.Messaging;

. .

.

MessageQueue[] msmques = MessageQueue.GetPrivateQueuesByMachine(".");
foreach (var item in msmques)
{
        MessageQueue.Delete(".\\"+item.QueueName);
}

cahit beyaz

Posted 2012-02-29T11:27:00.903

Reputation: 101