Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ?
JJ <[email protected]> Sun, 14 Dec 2025 08:00:35 +0700
| Newsgroups | alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On Fri, 28 Nov 2025 19:05:57 +0100, R.Wieser wrote:
> Hello all,
>
> I know that I can use wscript.stdout.write(line) (or just wscript.echo) and
> wscript.stdin.read(line) for that.
>
> The problem is that I need it to happen even when the script has its
> standard input/output redirected (imagine a console-based "do you want to
> continue (YN)" interaction)
>
> Using Win32 I can just open "CONIN$" and "CONOUT$", but I can't get those to
> work using OpenTextFile / CreateTextFile.
>
> Any ideas ?
>
> Regards,
> Rudy Wieser
Console input : "CON"/"CONIN$" with mode 1 (read)
Console output: "CON"/"CONOUT$" with mode 2 (write)
e.g.:
set fs = createobject("scripting.filesystemobject")
'read from standard input. redirected or not
strstd = wsh.stdin.readline
'read from console input. from keyboard
set coninp = fs.opentextfile("con", 1)
strcon = coninp.readline
'write to standard output. redirected or not
wsh.stdout.writeline strstd
'write to console output. to console window
set conout = fs.opentextfile("con", 2)
conout.writeline strcon