invoke a function synchronously

  • Thread starter Thread starter leochen76
  • Start date Start date
L

leochen76

Hi,

I have a procedure that executes an external vbscript file using
ShellExecute as listed below.
Immediately after that, I will read whatever in a text file which
is the output of that vbscript file.

The problem is that the vbscript file is executed asynchronously,
and I always end up opening an empty text file because the vbscript
file is still running. How can I wait until the vbscript is done?
Thanks a lot.

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" .....
 
Take a look intothe Process.Start method.

mProcess = New Process

With mProcess.StartInfo

.FileName = ("file.exe")

.Arguments = commandLineArgs

.UseShellExecute = False

.CreateNoWindow = True

End With

mProcess.Start()

mProcess.WaitForExit()
 
Back
Top