Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 0 down vote accepted

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.

share|improve this answer
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 Mar 6 '12 at 14:38
Ah, don't sweat it. I'm sure you can whip something up in mere minutes. – Carlos Mar 6 '12 at 15:47

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)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.