RE:Control de ejecución prog en MSDOS
'Coloca todo esto en un módulo
Private Const PROCESS_QUERY_INFORMATION = &H400
Private Const STILL_ACTIVE = &H103
Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess&, ByVal bInheritHandle&, _
ByVal dwProcessId&) As Long
Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Public Sub EsperarShell(comando As String)
Dim hShell As Long
Dim hProc As Long
Dim codExit As Long
' Ejecutar comando MS-DOS
hShell = Shell(Environ$("Comspec") & " /c " & comando, vbMinimizedNoFocus)
' Esperar a que se complete el proceso
hProc = OpenProcess(PROCESS_QUERY_INFORMATION, False, hShell)
Do
GetExitCodeProcess hProc, codExit
DoEvents
Loop While codExit = STILL_ACTIVE
End Sub
'Sólo llama a la función de esta forma, por ejemplo:
Call EsperarShell("autoexec.bat")