cancel
Showing results for 
Search instead for 
Did you mean: 

Run and Wait

Former Member
0 Kudos

I want to run another powerbuilder application exe from our main application when a user clicks on a menu item

I've seen examples of the run and wait.

Will this work with another pb .exe

My goal is to force the user to close the launched .exe before returning the "launching application"

Thanks

Richard

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Richard;

We use a very simple way to achieve two messaging between PB program;

launched .exe:

SendMessage(hwn,WM_SETTEXT,0,ref msg)

or

Send(hwn,WM_SETTEXT,0,ref msg)


hwn =handle(textbox) from the original PB applicatio.


This will trigger the original PB applicatio a textbox event pbm_settext


So that it can be very flexible to achieve the desired effect.



Also just interested can look at it: http://scn.sap.com/thread/3722995



Former Member
0 Kudos

To run & wait you can use the WScript object:

lole_wsh = CREATE OleObject

li_rc = lole_wsh.ConnectToNewObject ("WScript.Shell")

IF li_rc = 0 THEN

     li_rc = lole_wsh.Run (as_commandline, ai_windowstyle, ab_wait)

END IF

For more information: Run Method (Windows Script Host)

Former Member
0 Kudos

Hi Richard;

  Yes, this approach can be used successfully for what you want to accomplish. To make sure that the original PB application does not allow processing while the 2nd PB application is running, I would launch the "Run & Wait" from a Response window. I would have the Response window display a message to the user that it is "Waiting for Application XXX to complete". Being a response window, Application #1 should be modal at this point. Once Application #2 completes, the Run & Wait should be satisfied and it can now close the Response dialogue & reset the user's focus back to the application. The user should then be able to continue where they left off.  

HTH

Regards .... Chris

Former Member
0 Kudos

Hi,

or you use this free tool.

http://www.topwizprogramming.com/freecode_runandwait.html

RunandWait

This program shows how to execute other programs and wait for them to finish before continuing. Also shows how to automatically load a file into the program registered for that file type.

Win API Functions used:

CloseHandle
CreateProcess
ExpandEnvironmentStrings
GetExitCodeProcess
ShellExecuteEx
TerminateProcess
WaitForSingleObject

I use this and it works.


André Rust