Answered by:
Script error with MSMQ MP and Public Queueing discovery

Question
-
Hi
I´m geting script error while the discovery of Public Queues are beeing executed om my MSMQ server (win2k3)
I have a run as account that runs this ( validated in eventviewer that the account makes a logon before execute)
The error only comes on discovery of Public Queues (my private ones becomes discoverd ok)
In the Event Viewer of MSMQ-server it tells me this:
The process started at 14:04:04 failed to create System.Discovery.Data. Errors found in output:C:\Program Files\System Center Operations Manager 2007\Health Service State\Monitoring Host Temporary Files 11\843\DiscoverQueues.vbs(107, 4) Microsoft VBScript runtime error: Subscript out of range: '[number: 0]'
So then I looked at the script it self at Row 107 (Bold in the text below)
Function GetPublicQueues(Computer)
Dim PublicQueues()
ReDim PublicQueues(0)Set MSMQQuery = CreateObject("MSMQ.MSMQQuery")
On Error Resume Next
Set Queues = MSMQQuery.LookupQueue()
Set QueueInfo = Queues.Next
If Err = 0 Then
On Error GoTo 0
While Not QueueInfo Is Nothing
QueueServer = Split(QueueInfo.PathNameDNS,"\")(0)
If lcase(Computer) = lcase(QueueServer) Then
PublicQueues(UBound(PublicQueues)) = QueueInfo.PathName
ReDim Preserve PublicQueues(UBound(PublicQueues)+1)
End If
Set QueueInfo = Queues.Next
Wend
Else
Message = "Error searching Active Directory while discovering public queues." & VbCrLf & _
"Error number: " & Err.Number & VbCrLf & _
"Error Description: " & Err.Description
On Error GoTo 0
Call ThrowScriptError(EVENTNO_ERROR_ADLOOKUP,EVENT_LEVEL_ERROR,Message,False)
End If
ReDim Preserve PublicQueues(UBound(PublicQueues)-1)
GetPublicQueues = PublicQueues
End Function
Does anyone know why it gives me this error? Is there a problem with the last Queues.Next post of the array after it has been ReDim last in the while-loop?
Help appreciated- Edited by Olov Persson Wednesday, June 24, 2009 1:38 PM
Wednesday, June 24, 2009 1:33 PM
Answers
-
Does your queue name end in \?
Microsoft Corporation- Marked as answer by Vineet Kulkarni Monday, July 27, 2009 10:29 AM
Saturday, July 4, 2009 3:33 PM
All replies
-
Does your queue name end in \?
Microsoft Corporation- Marked as answer by Vineet Kulkarni Monday, July 27, 2009 10:29 AM
Saturday, July 4, 2009 3:33 PM -
I don't see how that is relevant?
QueueServer = Split(QueueInfo.PathNameDNS,"\")(0) This would return the first part of the array. If QueueInfo.PathNameDNS contains "SERVER01\public$\my.msmq.queue" then QueueServer (in the example) would contain "SERVER01".
Exception: Subscript out of range: '[number: 0] is returned when QueueInfo.PathNameDNS is empty or equals "".
Even if QueueInfo.PathNameDNS would contain a single "\" you would still not get an exception, just empty values. This error derives from an empty QueueInfo.PathNameDNS and poor error handling.
Here's a short example on how the Split function works.
Test1 = "Test1\Test1.1\Test1.2" ' Basically, what an MSMQ PathDNS should look like
Test2 = "Test2\Test2.1\" ' Supposedly an MSMQ Queue with "\" in the end (is that even possible?)
Test3 = "\" ' A single "\". Still splits fine, but with empty values
Test4 = "" ' Should split fine unless you try to read the first value (the (0) part)
WScript.Echo "Test1, should return Test1: "
sFirstValue = Split(Test1,"\")(0)
WScript.Echo sFirstValue
WScript.Echo "Test2, should return Test2: "
sFirstValue = Split(Test2,"\")(0)
WScript.Echo sFirstValue
WScript.Echo "Test2, should return an empty string: "
sFirstValue = Split(Test3,"\")(0)
WScript.Echo sFirstValue
WScript.Echo "Test2, should raise an exception: "
sFirstValue = Split(Test4,"\")
sFirstValue = Split(Test4,"\")(0)
WScript.Echo sFirstValue
- Edited by Samuel Tegenfeldt Monday, November 2, 2009 10:42 AM Weird code handling
Monday, November 2, 2009 10:40 AM