|
|
发表于 2009-4-22 21:03:40
|
显示全部楼层
我是知道这个实现方法,但没有具体应用过,所以也没代码
你可以查下wsh的wshscriptexec对象
此对象由wsh下的exec方法访问- 在子命令外壳程序中运行应用程序,提供对 StdIn/StdOut/StdErr 流的访问
复制代码 具体的输入输出访问是其中三个属性
StdOut 属性 | StdIn 属性 | StdErr 属性- 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
复制代码 |
|