Re: vbscript CSCRIPT howto : writie to screen and read from keyboard ?

Paul <[email protected]> Sat, 13 Dec 2025 16:55:54 -0500
Newsgroups alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general
Organization A noiseless patient Spider
Message-ID <[email protected]>
On Sat, 12/13/2025 11:51 AM, R.Wieser wrote:
> Mr. Man-wai Chang,
> 
>> https://www.google.com/search?q=vbscript+OpenTextFile+CreateTextFile+console{snip}
> 
> [quote=me]
> I can't get  those to work using OpenTextFile / CreateTextFile.
> [/quote]
> 
> And yes, I did search for the solution before posting here.  Alas, no dice.
> 
> Regards,
> Rudy Wieser
> 
> 

I asked CoPilot to write me something.

   Prepare a  vbscript CSCRIPT program which opens a window,
   accepts text input from the terminal session, then displays
   "You typed " followed by the text string, placing the text
   string on CONOUT and within the opened window, then waits
   for an additional carriage return to exit the program.

This is the resulting program.

*********************************************************
' Save this as input_echo.vbs
' Run with: cscript //nologo input_echo.vbs

Option Explicit

Dim WshShell, userInput, dummy

Set WshShell = CreateObject("WScript.Shell")

' Prompt for input from terminal
WScript.StdOut.Write "Type something: "
userInput = WScript.StdIn.ReadLine

' Echo to console
WScript.StdOut.WriteLine "You typed " & userInput

' Show in a popup window
WshShell.Popup "You typed " & userInput, 0, "Input Echo", 64

' Wait for carriage return before exit
WScript.StdOut.Write "Press ENTER to exit..."
dummy = WScript.StdIn.ReadLine

*********************************************************

This is the console session. The program blocks on the GUI,
so the GUI has to be OK'ed out first, then you can type
some input to exit the program. Oh, well. If this was a
homework assignment, the AI would not get full marks,
and I'd just have to deliver the query again with comments
added about non-blocking I/O for the GUI part.

PS S:\> cscript //nologo input_echo.vbs
Type something: Hello
You typed Hello
Press ENTER to exit...
PS S:\>

     [Picture]  Click "Download original" to escape the advertising swamp

      https://i.postimg.cc/Nfrb67QT/cscript-input-echo.gif

  Paul