determining if a shelled program has ended execution (vb3.0) 
Author Message
 determining if a shelled program has ended execution (vb3.0)

Hello!

I'm writing a program that require the results generated by another windows
3.1 application that is called from my program through the SHELL command,
BUT I want my program to stop execution and continue when the SHELLED app
is done.

I want my program to wait and check to see if the shelled app is done
executing and then continue with the next line of code.

Suggestions are much appreciated,
vinh.



Mon, 01 Feb 1999 03:00:00 GMT  
 determining if a shelled program has ended execution (vb3.0)

Quote:

> =
> Hello!
> =
> I'm writing a program that require the results generated by another win=
dows
> 3.1 application that is called from my program through the SHELL comman=
d,
> BUT I want my program to stop execution and continue when the SHELLED a=
pp
> is done.
> =
> I want my program to wait and check to see if the shelled app is done
> executing and then continue with the next line of code.
> =
> Suggestions are much appreciated,
> vinh.

Read the KB article :
How to Determine When a Shelled Process Has Terminated

Article ID: Q96844

-- =

Name: Andr=E9 Delcroix



Mon, 01 Feb 1999 03:00:00 GMT  
 determining if a shelled program has ended execution (vb3.0)


Quote:
> I'm writing a program that require the results generated by another windows
> 3.1 application that is called from my program through the SHELL command,
> BUT I want my program to stop execution and continue when the SHELLED app
> is done.

You should goto the Knowledge Base pages (see below) and do a little search
for something like "shell wait finish"

--
VB Info: http://www.sn.no/~balchen/vb/visual.htm
FAQ: http://www.sn.no/~balchen/vb/faq.htm
Knowledge Base: http://www.sn.no/~balchen/vb/kb.htm



Mon, 01 Feb 1999 03:00:00 GMT  
 determining if a shelled program has ended execution (vb3.0)

: Hello!

: I'm writing a program that require the results generated by another windows
: 3.1 application that is called from my program through the SHELL command,
: BUT I want my program to stop execution and continue when the SHELLED app
: is done.

: I want my program to wait and check to see if the shelled app is done
: executing and then continue with the next line of code.

: Suggestions are much appreciated,
: vinh.

Search <http://www.microsoft.com/kb> for GetModuleUsage.

--

WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Mon, 01 Feb 1999 03:00:00 GMT  
 determining if a shelled program has ended execution (vb3.0)



Quote:

>> I'm writing a program that require the results generated by another
windows
>> 3.1 application that is called from my program through the SHELL
command,
>> BUT I want my program to stop execution and continue when the SHELLED
app
>> is done.

>You should goto the Knowledge Base pages (see below) and do a little
search
>for something like "shell wait finish"

I've got the stuff from the knowledge base:

Use a function called GetModuleUsage:
Declare Function GetModuleUsage% Lib "Kernel" (ByVal hModule%)

and use it like this:
h=shell("MYPROG.EXE")
while GetModuleUsage(h)>0
  DoEvents
wend

Regards,
Saul

___________________________________________
Saul G. Behr
Analyst Programmer
Software Engineer
Geek
Concert Pianist
Card Sharp
Master of the Mystical Arts
Defeater of the Saxons
King over all England
Allright officer I'll come quietly



Sat, 06 Feb 1999 03:00:00 GMT  
 determining if a shelled program has ended execution (vb3.0)


: I've got the stuff from the knowledge base:
:
: Use a function called GetModuleUsage:
: Declare Function GetModuleUsage% Lib "Kernel" (ByVal hModule%)
:
: and use it like this:
: h=shell("MYPROG.EXE")
: while GetModuleUsage(h)>0
:   DoEvents
: wend

I have  a Shell command problem in a VB4 application running under NT:

x = shell("command.com /c mycmd < myinput >myoutput", 0)
open myoutput for input as 1
' I want to read the content of myoutput and write it to a textbox

It turned out that the content of the previous version of myoutput was shown
instead of the one from the latest run of that shell command.  It seemed
that the I/O redirection will not be completed until the VB application is
terminated.

So I force the VB code to wait for the completion of Shell as illustrated by
Mr. Behr.  But the de{*filter*} stopped at his While statement.  Is there
anything wrong with his code?

How may I force the completeion of I/O redirection in Shell before I open it
to read?

Jim Kung
Norfolk State University



Sun, 07 Feb 1999 03:00:00 GMT  
 determining if a shelled program has ended execution (vb3.0)

Quote:

> : I've got the stuff from the knowledge base:
> :
> : Use a function called GetModuleUsage:
> : Declare Function GetModuleUsage% Lib "Kernel" (ByVal hModule%)
> :
> : and use it like this:
> : h=shell("MYPROG.EXE")
>. : while GetModuleUsage(h)>0
>. :   DoEvents
> : wend

    The GetModuleUsage is a 16 BIT API call!!!!
    Your environment is running 32 bit code?
    Any questions?

Quote:
> I have  a Shell command problem in a VB4 application running under
NT:

> x = shell("command.com /c mycmd < myinput >myoutput", 0)
> open myoutput for input as 1
> ' I want to read the content of myoutput and write it to a textbox

> It turned out that the content of the previous version of myoutput
was shown
> instead of the one from the latest run of that shell command.  It
seemed
> that the I/O redirection will not be completed until the VB
application is
> terminated.

    How about "killing" the shelled process which should
    flush I/O buffers.

    Another idea might be to use a "memory mapped" file to do your
    I/O. It would have some speed advantages as your reading/writing
    RAM instead of SLOW disks.
    I think there was some code examples in a recent VB Prog.Journal
    last 3-4 months. I don't have my copies handy.

Quote:

> So I force the VB code to wait for the completion of Shell as
illustrated by
> Mr. Behr.  But the de{*filter*} stopped at his While statement.  Is there
> anything wrong with his code?

    I have ran into problems Debugging 32 bit code in the Borland
    environment also the Breakpoints that I set in the De{*filter*} never
    get reached or so it seemed, all I had to do was task switch to the
    de{*filter*} and the program was stopped right where I set the
    breakpoint.
    I think this is because in 32 bit processes the address space of all
    processes are shall we say "private".

Quote:
> How may I force the completeion of I/O redirection in Shell before I
open it
> to read?

> Jim Kung
> Norfolk State University


___________________________________________

If Pro is the opposite of Con.
What is the opposite of Progress?



Sun, 07 Feb 1999 03:00:00 GMT  
 determining if a shelled program has ended execution (vb3.0)

There is a book called "Visual Basic Programmer's Guide to the WIN32 API"
by Daniel Appleman which comes with a CD with that very same situation on
it.  I would suggest purchasing the book, its $50 but its 1500 pages of
info as well as the whole book on a cd format with samples too.  The sample
that I found was in chapter 14's samples and is called Launch.vbp,
basically you have to write a big involved sub using the results of your
shell command.  The text from the example is also in the book so you could
go to the bookstore and look at it there.


Quote:


> : Hello!

> : I'm writing a program that require the results generated by another
windows
> : 3.1 application that is called from my program through the SHELL
command,
> : BUT I want my program to stop execution and continue when the SHELLED
app
> : is done.

> : I want my program to wait and check to see if the shelled app is done
> : executing and then continue with the next line of code.



Tue, 09 Feb 1999 03:00:00 GMT  
 determining if a shelled program has ended execution (vb3.0)

Quote:

> There is a book called "Visual Basic Programmer's Guide to the WIN32 API"
> by Daniel Appleman which comes with a CD with that very same situation on
> it.  I would suggest purchasing the book, its $50 but its 1500 pages of
> info as well as the whole book on a cd format with samples too.  The sample
> that I found was in chapter 14's samples and is called Launch.vbp,
> basically you have to write a big involved sub using the results of your
> shell command.  The text from the example is also in the book so you could
> go to the bookstore and look at it there.

There's a KB article dealing with the 32-bit case as well. I
think it involves the WaitForSingleObject API. However, the
original question did specify VB 3.0 running on Windows 3.1,
which does support the GetModuleUsage API.

[snip]

--

WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Wed, 10 Feb 1999 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. ending a DOS shell after execution

2. Ending program execution

3. How a 32-Bit App Can Determine When a Shelled Process Ends, Article ID: Q129796

4. Help with Determining Shell Process Ends

5. How a 32-Bit App Can Determine When a Shelled Process Ends

6. Determine When shelled process end

7. Determining when a shelled process ends

8. How a 32-Bit APP can Determine When a Shelled Process Ends - Q129796

9. Help: How a 32-Bit app can determine when a shelled process ends

10. Determine whether a external program (process) has finished execution successfully

11. Shell execution of programs

12. SHELL and wait until the end of the program

 

 
Powered by phpBB® Forum Software