Reputation: 423
I would like to know how to display variable values in command prompt.
Following is the vbs
code:
For i=0 To 10
// I should display this variable value in command prompt
Next
If I write Shell.run
(a.bat
) inside loop, this will open command prompt 10 times.
But i want all 10 values to be displayed in single command prompt.
Upvotes: 4
Views: 47373
Reputation: 3179
[EDIT] Yes, if run the .vbs script via CSCRIPT then WScript.Echo will print to the prompt window, else will popup a message box. Then work with CSCRIPT you can use as well WScript.StdOut.Write and WScript.StdOut.WriteLine
For i = 0 To 10
WScript.StdOut.WriteLine i
Next
Also with Shell.Run you can get only the exit code, and to redirect the output from your .bat file, you'll need Shell.Exec method. There is a nice example on how to use Exec into Windows Script 5.6 Documentation. It's a must have doc file anyway.
Upvotes: 0
Reputation: 5046
Use WScript.Echo
:
For i = 0 To 10
WScript.Echo i
Next
You'll want to use CSCRIPT, either explicitly:
cscript vecho.vbs
Or make CSCRIPT the default:
cscript //H:CScript
Upvotes: 11