General discussion

Locked

VB - how to run another program

By swlovett ·
The catch here is that I want to wait until the program finishes before the program continues with the next statement,i.e. I want to run it sychronously rather than async, which is what shell does. There may be some way to start it with shell and then check the task id to see when it quits.

Thanks,
Steve

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

VB - how to run another program

by roc180 In reply to VB - how to run another p ...

There is a ShellAndWait API, where you can shell to an application and control will not be returned until the shelled application closes. If you want a VB example, drop me a line and I can Email it to you.

Neal Martinelli

Collapse -

VB - how to run another program

by swlovett In reply to VB - how to run another p ...

Poster rated this answer

Collapse -

VB - how to run another program

by mpdcsup In reply to VB - how to run another p ...

How about using a call-back?

Collapse -

VB - how to run another program

by swlovett In reply to VB - how to run another p ...

Poster rated this answer

Collapse -

VB - how to run another program

by A H In reply to VB - how to run another p ...

Declerations
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400
====
Code
====
Sub Shell32Bit(ByVal JobToDo As String)

Dim hProcess As Long
Dim RetVal As Long
'The next line launches JobToDo as icon,

'captures process ID
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, 1))

Do

'Get the status of the process
GetExitCodeProcess hProcess, RetVal

'Sleep command recommended as well as DoEvents
DoEvents: Sleep 100


Loop While RetVal = STILL_ACTIVE
End Sub

Collapse -

VB - how to run another program

by swlovett In reply to VB - how to run another p ...

Poster rated this answer

Collapse -

VB - how to run another program

by swlovett In reply to VB - how to run another p ...

This question was closed by the author

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums