synchronous execution 
Author Message
 synchronous execution

Is there a way to execute multiple .exe's from within a VB 5.0 program
synchronously?

Shell executes asynchronously and my app finishes running before all of
the programs have a chance to execute.  This is a problem =].  Is there
either a different function to execute a .exe or is there a way to make
my app wait for each external .exe finish executing before continuing?

Thanks in advance for any help





Tue, 15 Feb 2000 03:00:00 GMT  
 synchronous execution

Mark,



Quote:
>Is there a way to execute multiple .exe's from within a VB 5.0 program
>synchronously?

Yes, there are some ways:

1. Knowledge Base Q129796 - for Win32 - with lots of API Calls
2. Knowledge Base Q96944  - for Win16 - with 'GetModuleUsage'
3. The quick and dirty (and most effective) way, without any API.

This one works with Win16 as well as with Win32 or Win NT:

- put the name of the DOS/Windows program you want to call
  in a batch file,
  name it "Xy.Bat",
- the last line in the batch file must be:
  ==========
  del Xy.Bat
  ==========
  It means, the batch file kills itself, as soon as the job is done.

 - Code segment in the program:

   'In the declaration:
   #If Win16 then
       Dim Res As Integer
   #Else
       Dim Res As Long
   #End If

    'set the working directory to current - to prevent from
    ' "file not found" error, or use fully qualified path from the
    ' root.    
    ChDrive App.Path
    ChDir App.Path

    'does "Xy.Bat" exist ?
    If Dir$("Xy.Bat") <> "" Then

        'set vbHideFocus if you don't want to see the Dos-window
        Res = Shell("COMMAND.COM /C Xy.Bat", vbNormalFocus)

        If Res = 0 then  'Shell fails          
           '? MsgBox "?"
           '? Exit Sub
        End If          

        Do While (Dir$("Xy.Bat") <> "") 'wait while Xy.Bat exists
            DoEvents                    'let Shell work
        Loop

    End If

Hint: you can create a batch file also in program code:

Dim handle As Integer

    handle = FreeFile  
    Open "Xy.Bat" For Output As #handle  
    Print#handle "..." ' <- your DOS command here
    Print#handle "..." ' <- your DOS command here
    Print#handle "del Xy.Bat"
    Close#handle

Peter



Tue, 15 Feb 2000 03:00:00 GMT  
 synchronous execution

Quote:

> Is there a way to execute multiple .exe's from within a VB 5.0 program
> synchronously?

> Shell executes asynchronously and my app finishes running before all
> of
> the programs have a chance to execute.  This is a problem =].  Is
> there
> either a different function to execute a .exe or is there a way to
> make
> my app wait for each external .exe finish executing before continuing?

> Thanks in advance for any help




Got the same problem.. could you forward anything you get to me thanx !
--


"Girl I'm gonna make you sweat, sweat till you can't wait no
 more !" - Inner Circle



Sun, 20 Feb 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. synchronous execution

2. Synchronous execution

3. synchronous execution

4. synchronous program execution

5. current time of execution during this execution.

6. current time of execution during this execution

7. Synchronous Shell

8. Multiple Emails Through Outlook not Synchronous

9. Synchronous Replication

10. Procedure in synchronous mode? Need help please

11. Synchronous shelling?

12. Using a synchronous component in an asynchronous component

 

 
Powered by phpBB® Forum Software