The Rexec/Rshell work fine in an .exe but not in a .DLL?

In using the Rexec control from a VB application such as your demo, the Rexec processing occurs synchronously and control is not passed back to the calling program until the Rexec command(s) are complete on the remote host. When I try to call these same functions by building the VB code into a DLL, however, the "Connected" event fires and then control is passed back to the calling routine. The Stdout, Stderr, Error and Disconnected events are not triggered and the calling program receives control prior to completion of the rexec command on the remote host. We would like to see the same synchronous operation with the DLL as with the VB EXE. Is there any way to force this to occur?

Date Entered: 09/04/1997    Last Updated: 06/11/2004

Actually, they don't wait in the EXE either: the control does always return immediately, so that the application may send data through the Stdin property if necessary. As you can see, this cannot work synchronously: if the operation was synchronous, there would be no way to interact with the application once the command was issued. When the command is finished, the component will disconnect.

SOLUTION: Simply enter a Loop doing DoEvents until the Disconnected event is fired (you can set a flag in the Disconnected Event to check this).


We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at kb@nsoftware.com.