I am working with a piece of VBScript where I am calling another application,
and can't seem to kill the application.
I have the following code:
Dim objShell : Set objShell = CreateObject("WScript.Shell")
Dim objReturn : Set objReturn = objShell.Exec("c:\my_app\my_app.exe opt=one")
Do While (objReturn.Status = 0)
if (len(objReturn.StdErr.ReadAll) > 0) then
objShell.LogEvent AnError, ("Page Me - App Failure: " &
objReturn.StdErr.ReadAll)
Set objReturn = Nothing
Set objShell = Nothing
Exit Function
end if
wscript.sleep 100
Loop
However this method is holding in an infinite loop. I have tried using the
following code after the exec:
Dim sSearch, sSearching : sSearching = "Completed Successfully!"
Do while not (inStr(sSearch, sSearching) > 0)
if (len(objReturn.StdOut.ReadAll) > 0) then
sSearch = sSearch & objReturn.StdOut.ReadAll
end if
wscript.sleep 100
Loop
objReturn.Terminate
wscript.quit(0)
This closes the child window ... but leaves a wscript process running in the
background. Any idea as to why this may be? Or how I should better script
this? I prefer to use the exec method over the run method to have access to
StdOut and StdErr so I would prefer ideas that include exec, not run.
Thanks,
Tom