Project1.exe 'The program to be shelled and return a code Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long) Private Sub Form_Unload(Cancel As Integer) ExitProcess 5 End Sub Project2.exe 'The program to call project1 and get the exit code Option Explicit Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Declare Function timeGetTime Lib "winmm.dll" () As Long 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 Const STILL_ACTIVE = &H103 Private Const PROCESS_QUERY_INFORMATION = &H400 Private Sub Command1_Click() Dim lngWait As Long Dim lngStart As Long Dim hProcess As Long hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell("C:\project1.exe")) lngStart = timeGetTime() Do GetExitCodeProcess hProcess, lngWait DoEvents: Sleep 100 If (timeGetTime() - lngStart > 2000000000) Then MsgBox "The process has timed out." lngWait = 0 End If Loop While lngWait = STILL_ACTIVE MsgBox lngWait End Sub