Here is the Shell Wait code I use in most of my apps (VB6):
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
Sub Shell32Bit(ByVal JobToDo As String)
  On Error Resume Next
  Dim hProcess As Long
  Dim RetVal As Long
  hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, 3))
    Do
      GetExitCodeProcess hProcess, RetVal
      DoEvents: Sleep 100
    Loop While RetVal = STILL_ACTIVE
End Sub
Example Use = Shell32Bit ("C:\MAME -fulllist > C:\ROMDUMP.txt")