Running a program after another using shell statement 
Author Message
 Running a program after another using shell statement

Hi there,

I'm running a program with the shell statement (e.g. shell ("c:\test.exe"))
and i want to run another program, but just when the first one ends.

Does anyone can help me with this?!
Thanks in advance.

Pedro.



Sat, 24 Jul 2004 20:51:43 GMT  
 Running a program after another using shell statement
Pedro,

See www.mvps.org for CreateProcess() API usage.

Alternatively, read up in MSDN about the Windows Scripting Host and the
IWSH_Shell interface.  It's VB-callable, and provides convenient methods for
DOS-like functionality.

--A



Sun, 25 Jul 2004 02:44:01 GMT  
 Running a program after another using shell statement


Quote:
> Hi there,

> I'm running a program with the shell statement (e.g. shell
("c:\test.exe"))
> and i want to run another program, but just when the first one ends.

> Does anyone can help me with this?!
> Thanks in advance.

I'm not sure where I found this function but it does the trick.

Public Function ExecCmd(Cmdline$) As Boolean
On Error GoTo 10
Dim phnd&, ret&
    ' Use Shell fn to launch, get a process handle
    ret& = Shell(Cmdline$, vbNormalFocus)
    If (ret& <> 0) Then
    ' Open the process, using handle retrieved from Shell
        phnd& = OpenProcess(SYNCHRONIZE, 0, ret&)
        If (phnd& <> 0) Then
            ' If OpenProc was successful, wait for the object to finish
        Call WaitForSingleObject(phnd&, INFINITE)
        ' Close the object
            Call CloseHandle(phnd&)
        End If
        ret& = phnd&
    End If
    ExecCmd = CBool(ret&)
GoTo 20
10 ExecCmd = False
   Resume 20
20
End Function



Sun, 25 Jul 2004 03:53:53 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Returning a value from a program that is running using the Shell command

2. Using the Shell function to run a program asynchronously

3. Shell program: running IE in Shell

4. Terminating a program started with the SHELL statement

5. Run programs by Wscript.shell

6. Running a DOS program as a Shell (PkUnzip) from VB

7. Running Programs in DOS Shell

8. redirect output of program run with shell command

9. Running VB5 programs from CD without using a setup program

10. Dos programs (shell) running in VB5

11. Getting a SHELL program to run invisibly

12. Sequential run of DOS program via SHELL command

 

 
Powered by phpBB® Forum Software