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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shellexecute problem with child processes from VFP8 1

Status
Not open for further replies.

coldbohemia

Programmer
Jun 5, 2008
30
US
i'm launching an independent process from microsoft visual foxpro 8.0 sp1 with the "shellexecute" command
the target is an exe program written in clipper 5.2e
the clipper runs fine as long as the foxpro program that
launched it is active, but terminates prematurely
if i quit visual foxpro

is there a way to launch (spawn) an independent process
from visual foxpro that windows doesn't consider a child
process of the calling program?

thanks..
 
is there a way to launch (spawn) an independent process
from visual foxpro that windows doesn't consider a child
process of the calling program?

That is exactly what ShellExecute() does. Once the child has been launched, there's no connection with the launching program, and no reason why it shouldn't carry on running once the launcher has closed.

Either you are doing something wrong in your ShellExecute(), or there is something special in the Clipper app that makes it dependent on the FoxPro app in some way.

Can you post a copy of the code you are using to launch the Clipper app?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Just to be clear, here's an example of some ShellExecute() code. You might want to check that yours is similar:

Code:
* Do this once only, near the start of your app.
DECLARE INTEGER ShellExecute IN shell32.dll ; 
  INTEGER hndWin, ; 
  STRING cAction, ; 
  STRING cFileName, ; 
  STRING cParams, ;  
  STRING cDir, ; 
  INTEGER nShowWin

* And do this when you want to launch your Clipper app
cFileName = "c:\Program Files\MyApp\MyClipper.Exe" 
cAction = "open" 
ShellExecute(0,cAction,cFileName,"","",1)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
thank you for your prompt response , mike .
i had left for lunch and just came back

here's the code :

============
declare integer ShellExecute in ;
shell32.dll ;
integer nShellhndWin,;
string cShellAction,;
string cShellFileName,;
string cShellParams,;
string cShellDir ,;
integer nShellShowWin

cShellFileName = ntx_launcher
cShellAction = "open"
cShellDir = RPTSFOLDER
n_shell_return_code = ShellExecute(0,cShellAction,cShellFileName,"",cShellDir ,1)

set Step on
===================


ntx_launcher is batch file that i'm creating with foxpro,
it calls a clipper exe program


the shellexecute command returns code 42, which i understand is a good number (anything above 31 or 32?)

with "set step on" the process finishes;
but if i close the form it terminates prematurely
"ntx_launcher" is a variable that contains
the name of a batch file on another pc on the network

RPTSFOLDER is a #define(d) constant inside an include file
i'm not sure i need to include this,
as the batch file includes the path names of the exe
and file involved
 
Apart from launching the Clipper app, what else is the batch file doing? Does it include a command that might cause the system to wait for input?

Apart from that, I can't see anything untoward in your code. You're right that a returned value higher than 32 indicates success (but, of course, that only means you have successfully launched the batch file, not necessarily that it has run all the way through).

One other possibility: Have you tried running the batch file via the RUN command (without the /N parameter)?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
thanks mike

i'm going to try the run command,
although i don't like being defeated by
an (&)&(*, obscure, badly-documented foxpro command
it leaves a bad taste
joe

 
Joe,

Yes, I know what you mean. ShellExecute() should work. It's just that it's a Windows function, and batch files and Clipper are in the DOS world.

Let us know if you solve it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 


this works.
i don't like it, but it works.

the foxpro program that spawns the dos clipper prog
also creates an empty text file,
and goes into a do while loop until the
"file()" function no longer sees this file, then
terminates.

(the spawned clipper program deletes this file when
it finishes).

don't laugh, it works










 
Have you tried the dos level "START" command?

Call it via the VFP run command.

RUN start <clipper exe here>

or

!start <clipper exe here>



Alan
 

i will try it Alan
but later, i need to get past this
hump first so i can finish the thing
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top