inOut.vbs for stdIn to stdOut

@Romanv, I hope this helps you:

Create the file: inOut.vbs with the following code:

' Description:
' Used to take input from StdIn (most commonly from another programs StdOut)
' and output (append) the content it is given to the file c:\output.txt
'
' Jeremy A. Snyder
' Created: 24-Feb-2009
'
' examples:
' dir | cscript inOut.vbs
' or chp cmd /c "dir c:\ | cscript inOut.vbs"
'
Dim fso, strm, filename
' Set filename, and appending(8) mode
' if not outputting to a file, these lines can be deleted.
filename = "c:\output.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set strm = fso.OpenTextFile(fileName, 8, True)
Do Until WScript.StdIn.AtEndOfStream
strLine = WScript.StdIn.ReadLine
' here is where the action happens based on the line read in:
strm.WriteLine strLine
Loop

http://www.commandline.co.uk/chp/

And you can now do the following:

chp.exe cmd.exe /c "dir c:\ | cscript c:\inOut.vbs"

and it will produce a file: c:\output.txt that contains the directory listing of c:\ in it.

You can modify the inOut.vbs to do something with the lines it reads off the StdIn stream (instead of writing them out to a file). And you can change the command that runs (dir c:\) in the above example to anything that outputs to StdOut the data you require.

NOTE:
If you do:

chp.exe cmd.exe /c "dir c:\" | cscript c:\inOut.vbs

You will only get the PID of the cmd.exe command (as that is the only output from chp.exe)… and not the output of the “dir c:\” comand.

Hope this helps!
Jeremy