Forum Discussion

dbc680's avatar
dbc680
New Contributor
5 years ago
Solved

Get list of Private Queues using JavaScript

I just need to get a list of the current private message queues (MSMQ). Not the actual messages, just the name of the queues. Preferably in JavaScript. It doesn't appear to be anywhere in the registry. I also tried looking through the available functions in "dotNET" and "dotNET.System" but don't really see anything about messaging. Is there a way to do this?

  • I figured it out! Had to query the WMI object: 

    // Query WMI for Message Queues
    var privateQueueNames = [];
    var Locator = getActiveXObject("WbemScripting.SWbemLocator");
    Locator.Security_.ImpersonationLevel = 3;
    var wmiobj = Locator.ConnectServer(".", "root\\cimv2");
    var queryresults = wmiobj.ExecQuery("Select * from Win32_PerfRawdata_MSMQ_MSMQQueue Where Name like \"%private%\"");
    // Push all queue names into privateQueueNames
    for( var items = new Enumerator(queryresults); !items.atEnd(); items.moveNext() )
      privateQueueNames.push(items.item().Name);
    // Convert the function elements into strings
    privateQueueNames = privateQueueNames.join();
    privateQueueNames = privateQueueNames.split(",");
    Log.Message(privateQueueNames);

3 Replies