I think there are various ways to accomplish this, but I always use CreateProcess and WaitForSingleObject for this.
CreateProcess will provide you with a handle to the newly created process and, by supplying this handle to the WaitForSingleObject, you can wait for the process to have been terminated.
Greetings,
Rick
As an option to the one posited by LazyMe, you can use the Windows Host Scripting Object, which you add as a project reference.
Dim RetVal As Long
Dim WSH As IWshShell
Dim WaitForTerm as Boolean
Dim CommandLine as String
Set WSH = New IWshShell_Class
CommandLine = "notepad.exe"
WaitForTerm = True
RetVal = WSH.Run(CommandLine, vbNormalFocus, WaitForTerm)
' MsgBox "Process returned: " & RetVal
Set WSH = Nothing Good Luck
-------------- As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
Thank you for your helpful replies. If I need to create a batch file to open a process, how can I get the handle for the new window opened by the batch? Should this be a new thread?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.