顯示 Exec 對(duì)象的只寫 stdout 輸出流。
Object.StdOut
StdOut 屬性中包含腳本可能已發(fā)送到標(biāo)準(zhǔn)輸出的任何信息的只讀副本。
下面的代碼啟動(dòng)一個(gè)批文件后等待用戶輸入提示。通過 StdIn 流輸入所需數(shù)據(jù)之后該批文件結(jié)束。
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);