显示 Exec 对象的只写 stdout 输出流。
Object.StdOut
StdOut 属性中包含脚本可能已发送到标准输出的任何信息的只读副本。
下面的代码启动一个批文件后等待用户输入提示。通过 StdIn 流输入所需数据之后该批文件结束。
Dim WshShell, oExec, input Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("test.bat") input = "" Do While True If Not oExec.StdOut
.AtEndOfStream Then input = input & oExec.StdOut
.Read(1) If InStr(input, "Press any key") <> 0 Then Exit Do End If WScript.Sleep 100 Loop oExec.StdIn.Write VbCrLf Do While oExec.Status <> 1 WScript.Sleep 100 Loop
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("test.bat");
var input = "";
while (true)
{
if (!oExec.StdOut.AtEndOfStream)
{
input += oExec.StdOut.Read(1);
if (input.indexOf("Press any key") != -1)
break;
}
WScript.Sleep(100);
}
oExec.StdIn.Write("\n");
while (oExec.Status != 1)
WScript.Sleep(100);