cscript - print output on same line on console?

Guy picture Guy · May 24, 2010 · Viewed 20.5k times · Source

If I have a cscript that outputs lines to the screen, how do I avoid the "line feed" after each print?

Example:

for a = 1 to 10
  WScript.Print "."
  REM (do something)
next

The expected output should be:

..........

Not:

.
.  
.
.
.
.
.
.
.
.

In the past I've used to print the "up arrow character" ASCII code. Can this be done in cscript?

ANSWER

Print on the same line, without the extra CR/LF

for a=1 to 15
  wscript.stdout.write a
  wscript.stdout.write chr(13)
  wscript.sleep 200
next

Answer

naivnomore picture naivnomore · May 24, 2010

Use WScript.StdOut.Write() instead of WScript.Print().