In my VB6 program, I’m running certain DOS command using .Exec call. I also read the command’s standard output – StdOut. In the first stage of testing, I read the entire output into some string variable (using .ReadAll). Then I realized that the information I’m looking for can be found in first five to seven lines (where the whole output is hundreds lines long). In my program I can proceed after finding the information I need, but the DOS window remains opened – I have to read the whole output to finish the command, then DOS window closes.
Is there a way to programmatically “kill” the command (like you using <ctrl>C) before command reaches its end?
Is there a way to programmatically “kill” the command (like you using <ctrl>C) before command reaches its end?
Code:
Set oWShell = CreateObject("WScript.Shell")
sCmd = " ... "
Set oExe = oWShell.Exec(sCmd)
Do
sTmp = oExe.StdOut.ReadLine()
While Not sTmp = “”
...
sTmp = oExe.StdOut.ReadLine()
Wend
[COLOR=#CC0000]At this point I’d like to kill the executed command[/color]
...
...
Loop