- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I need some help with controlling the execution of a .EXE file from my Fortran code. I have to configure and call an application from my code. To do this, I write all the necessary inputs into a text file, and I call the .EXE together with the input via a batch file, using SYSTEM = RESULT (C:\MyCode\App.bat). The problem is that the external application (App.exe) is not 100% reliable, and sometimes it just blocks during execution, also blocking my code on the SYSTEM = RESULT line. If I terminate the external program manually (for ex. I simply use End Process from Win Task Manager), my code can continue without problems. However, I have to perform hundreds of calls of the external App.exe, over several hours, and I need to find a way to automatically terminate it when things go bad. I want to know if there is any way of monitoring, from within my code, the progress of the App.exe, and to terminate it if, for example, it has not finished in a given amount of time (knowing that a "normal" execution should take a couple of minutes).
I am only a beginner in programming, please answer keeping this in mind. Thanks a lot for your help.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use CreateProcess. http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
For running a batch file, the process you create should run "CMD.EXE /c YourBatchFile.bat arg, arg, arg"
A return value includes a pointer to the new process information. In there, is a handle to the new process. You can use this handle to terminate the process (e.g. after timeout with no progress).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
jimdempseyatthecove wrote:
Use CreateProcess. http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
For running a batch file, the process you create should run "CMD.EXE /c YourBatchFile.bat arg, arg, arg"
A return value includes a pointer to the new process information. In there, is a handle to the new process. You can use this handle to terminate the process (e.g. after timeout with no progress).
Jim Dempsey
Thanks a lot, but I am not certain how to implement it using a Fortran compiler, all the details in the link refer only to C++ implementation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page