Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

albi73

Programmer
Sep 16, 2010
18
IT
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:

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


In this case this trick doesn't work

I thought to make the follow:

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


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.

 
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:
Set WshShell = WScript.CreateObject("WScript.Shell")
' Assuming this P1 is on the title bar of P1
WshShell.AppActivate "P1"
WshShell.SendKeys "{ENTER}"
Code:
call system('cscript.exe killp1.vbs')
4) If the system call does not return immediately then try launching it as a separate process
Code:
call system('start P1.exe input_file')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top