Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running Multiple Windows EXEs Within FoxPro
Message
From
01/01/1999 20:03:18
 
 
To
01/01/1999 15:47:35
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00171620
Message ID:
00172112
Views:
23
>>>Thanks for your response - It looks like it *should* work but I'm having the same results. Control comes back to FoxPro as soon as the RUN APP1.BAT executes, with the FILE1.DAT deleted and it falls thru.
>>
>>Of course, how basic of me... The .bat does the same thing; run the program and continue on without waiting for the .exe to end... Next time I'll try thinking before posting! :-)
>>
>>I'll think about that and come back if I think of something... Sorry for the error!
>
>If you insert the CALL command:
>
>App1.bat:
>@ECHO OFF
>CALL APP1.EXE
>DEL FILE1.DAT
>
>App2.bat:
>@ECHO OFF
>CALL APP2.EXE
>DEL FILE2.DAT
>
>the batch files should work the way you want them to.
>

Better yet, use CreateProcess() or ShellExecuteEx() to run the application (or batch file; you can launch .BAT files with either, and using the process handle returned from the API call, you can monitor if the application is still running or has finished. Make certain to terminate the .BAT file with an EXIT statement to ensure that the VDM gets shut down and fully returns control to VFP.

You can use the API_APPRUN class I posted to run a batch file with or without waiting for it to terminate, and can monitor the termination code from DOS and Windows apps. It's in the FAQ under the Classes category. It allows you to specify the Window mode for the running application or batch file as well.

You can also run batch files (and -lots- more) through the Windows Scripting host; the Wscript.Shell object has a Run method that can wait on process termination, and you can launch and wait on scripts for the Windows Scripting Host that include VBScript and JScript by invoking WSCRIPT.EXE, a part of the Windows Scripting Host, through CreateProcess() and ShellExecuteEx(). This gives you the ability to build complex scripts on the fly and run them from within a VFP application.

John Petersen did a recent article on some of the WSH features, specifically the Wscript.Shell and Wscript.Network automation objects in FoxTalk. It's a good starting point for learning about scripting in the Windows environment. The MSDN contains a great deal of information about the scriupting host; you can start with the Windows Scripting Host, WshNetwork Object and WshShell Object topics. And there are a number of good web sites as well; take a look at Scripting tools for 32bit Windows operating systems
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform