Show output from child scripts in the parent console window

妖精的绣舞 提交于 2019-12-04 15:59:18
Ekkehard.Horner

You should try to use .Exec and .Stdout.Readline() as in this bare bone demo script:

mother.vbs

Option Explicit

Dim oWS : Set oWS = CreateObject("WScript.Shell")
WScript.Echo "A", "mother starts child"
Dim oEx : Set oEx = oWS.Exec("cscript child.vbs")
Do Until oEx.Stdout.AtEndOfStream
   WScript.Echo oEx.Stdout.ReadLine()
Loop
WScript.Echo "B", "mother done"

child.vbs:

Option Explicit

Dim n
For n = 1 To 5
    WScript.Echo n, "child"
Next

output:

cscript mother.vbs
A mother starts child
1 child
2 child
3 child
4 child
5 child
B mother done

Added:

see Pythonic version

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!