How can I wait the shell command to finish before execute to next statement?
Posted on 2004-04-13
MY VB program will execute another .exe file, using ShellExecute command. The .exe file will generate another large file which will spend around 1 hour. I've tried to get the return value of ShellExecute:
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
Dim StartDoc as long
StartDoc = ShellExecute(Scr_hDC, "Open", "c:\IMR\abc.exe ", "parameter", "", SW_SHOWMAXIMIZED)
abc.exe will spend 1 hr to finish and wil create another .txt file. I want to check if the .txt can be generated successfully before alert "Complete". However, the above "Complete" message will popup immediately instead of waiting for abc.exe really complete.
Any alternatives to solve this problem?