INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

challenging: program stoped on a procedure launched by call system()

challenging: program stoped on a procedure launched by call system()

challenging: program stoped on a procedure launched by call system()

(OP)
Dear friends,

my issue is the following:
I would like to close a "program" (named P1, for semplicity),
launched by a my exe (P2) (which uses "call sysemt ('P1.exe input_file').)

This software (P1), of which I haven't the source, to be closed (and return the control to P2),
needs to push a virtual button by mouse.

I alreay managed a problem like this which i solved as follow:

open(50,name='input.in',status='replace'); write(50,*) " ";close(50)
call system('P1 input_file < input.in') 


In this case this trick doesn't work

I thought to make the follow:

open(50,name='input.in',status='replace'); write(50,*) " ";close(50)
call system('P1 input_file < input.in')
call system('taskkill /im /P1 /F') 


also in this mode the problem is not solved, cleary the istruction 'taskkill /im /P1 /F is nether reached by
the code, becouse it doesn't reach the end of P2.

RE: challenging: program stoped on a procedure launched by call system()

1) The operation of system is different on every implementation. Does your system return immediately or only when execution of P1 has finished?
2) Your taskkill command is incorrect. It should be

CODE

taskkill /im P1.exe /f 
3) If system call returns immediately, then you could launch a vbscript process to do a SendKeys to the P1 gui.

CODE --> killp1.vbs

Set WshShell = WScript.CreateObject("WScript.Shell")
' Assuming this P1 is on the title bar of P1
WshShell.AppActivate "P1"
WshShell.SendKeys "{ENTER}" 

CODE --> FortranPart

call system('cscript.exe killp1.vbs') 
4) If the system call does not return immediately then try launching it as a separate process

CODE --> RunAsSeparateProcess

call system('start P1.exe input_file') 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close