Sign in to follow this  
Followers 0
ale1981

Windows Private Message Queues

14 posts in this topic

I need to create an application that deals with the Windows Private Message Queues and XMLs.

We use a program which creates XML files and places them into queues in windows.

I will need to access the queues and work with the messages?

Any kind of help will be appreciated.

Share this post


Link to post
Share on other sites



I need to create an application that deals with the Windows Private Message Queues and XMLs.

We use a program which creates XML files and places them into queues in windows.

I will need to access the queues and work with the messages?

Any kind of help will be appreciated.

There is a scripting object available if MSMQ is installed (Control Panel/Windows Components/Message Queuing), though I have no experience with it. I would love to see one of the smart people post a simple demo that opened a local (private) destination queue, then opened an output queue to it and transferred a simple piece of data. Translated from a VBS fragment found on the web:

Global $sMsmqQue = "MyQueueName" 
Global $oMSMQ = ObjCreate("MSMQ.MSMQManagement")
$oMSMQ.Init(@ComputerName, "", "DIRECT=OS:" & @ComputerName & "\private$\" & $sMsmqQue)
$iMsmqCnt = $oMSMQ.MessageCount 
MsgBox(64, "Count", "Current message count is: " & $iMsmqCnt)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks. Yes I have Message Queuing installed. I have found the .NET code that connects / reads / writes to a que;

WRITE

System.Messaging.MessageQueue queue = new
System.Messaging.MessageQueue(".\\Private$\\MyPrivateQueue");
queue.Send("Hello world");

READ
System.Messaging.MessageQueue queue = new
    System.Messaging.MessageQueue(".\\Private$\\MyPrivateQueue");
queue.Send("Hello world");
System.Messaging.Message msg = queue.Receive();
msg.Formatter = new System.Messaging.XmlMessageFormatter(
    new string[] {"System.String"});
Console.WriteLine(msg.Body);

Share this post


Link to post
Share on other sites

Thanks. Yes I have Message Queuing installed. I have found the .NET code that connects / reads / writes to a que;

WRITE

System.Messaging.MessageQueue queue = new
System.Messaging.MessageQueue(".\\Private$\\MyPrivateQueue");
queue.Send("Hello world");

READ
System.Messaging.MessageQueue queue = new
    System.Messaging.MessageQueue(".\\Private$\\MyPrivateQueue");
queue.Send("Hello world");
System.Messaging.Message msg = queue.Receive();
msg.Formatter = new System.Messaging.XmlMessageFormatter(
    new string[] {"System.String"});
Console.WriteLine(msg.Body);
I doesn't help me to see .NET code (smarter people my be able to use it), because that would use libraries loaded into that compiler and not available to AutoIt. Do you have such an example in a scripting language like VBS? This succeeds in creating the initial MSMQ object, but the .init fails:
Global $sMsmqQue = "Private$\MyPrivateQueue", $sXmt = "Hello, world!", $sRcv
Global $oMSMQ = ObjCreate("MSMQ.MSMQManagement")
$oMSMQ.Init(@ComputerName, "", "DIRECT=OS:" & @ComputerName & "\" & $sMsmqQue)
$oMSMQ.Send($sXmt)
$sRcv = $oMSMQ.Receive
MsgBox(64, "Results", "Message is: " & $sRcv)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I cant seem to find any VBS anywhere!

I managed to get your original script;

Global $sMsmqQue = "MyQueueName"
Global $oMSMQ = ObjCreate("MSMQ.MSMQManagement")
$oMSMQ.Init(@ComputerName, "", "DIRECT=OS:" & @ComputerName & "\private$\" & $sMsmqQue)
$iMsmqCnt = $oMSMQ.MessageCount
MsgBox(64, "Count", "Current message count is: " & $iMsmqCnt)

.. working once, but now the .init fails also.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

That looks like it should be very helpful, but I'm not making it work in AutoIt. This fails:
Global $sMsmqQue = "Private$\MyPrivateQueue", $sXmt = "Hello, world!", $sRcv
Global $oMSMQ = ObjCreate("MSMQ.MSMQQueueInfo")
$oMSMQ.PathName = $sMsmqQue
$oMSMQ.Create
$oMSMQ.Send($sXmt)

Interestingly, it doesn't fail until the .Create method.

I think the problem is that page references Visual Basic (vice VB Script), and assumes some libraries available to the compiler that include syntax/objects/methods/properties that we can't get to in AutoIt using the scripting object. Still looking for smart people to interpret...

:)

Edit: Typo

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

bump.....!

Share this post


Link to post
Share on other sites

Nobody ever get this to work?!

Share this post


Link to post
Share on other sites

.... bump .... anybody manage to get anything related to queues working?!

Share this post


Link to post
Share on other sites

@All

Maybe this can get you going.

; Initialize error handler 
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$PlumbApp = ObjCreate("MSMQ.MSMQApplication")
$PlumbQArray = $PlumbApp.ActiveQueues
For $PlumbQFormatName in $PlumbApp.ActiveQueues
   Dim $Mgmt 
   $Mgmt = ObjCreate("MSMQ.MSMQManagement")
   $Mgmt.Init (Default,Default,$PlumbQFormatName)
   ConsoleWrite("There are " & $Mgmt.MessageCount & " Messages in " & $PlumbQFormatName & @CR)
Next 
 
 ;This is custom error handler
Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"LogParser COM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
Endfunc

Regards

ptrex

Share this post


Link to post
Share on other sites

Hi ptrex,

I can not work out how to do this for a remote computer, the code you supplied will list the active queues on the computer the script is run?

Thanks again.

Share this post


Link to post
Share on other sites

bump.... :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0