Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WScript.Echo dump to a .txt file

Status
Not open for further replies.

BobSakemano

Technical User
Feb 17, 2005
20
0
0
NL
hey guys,

simple question. I want the values from a WScript.Echo to be dummped in to a .txt file.

I'v tries this:

Dim X
X = "txttxtxtxtxtxtt"
WScript.Echo X > c:\test.txt

doesnt work hoever.

any ideas?
 
Take a look at FileSystemObject

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
If you're using CScript, then:

cscript MyScript.vbs > MyOutput.txt

If you're using WScript then you need the file writing commands. Look at the example for TextStreamObject.
 
Hello Bobsakemano!

If you want to use the echo command to output to a text file, then you'll need to execute your script using the following syntax at a command line (or via the shell.run):
Code:
cscript.exe //E:VBScript //NoLogo script.vbs >>C:\test.txt
First, use cscript.exe and not wscript.exe. Cscript will put the echo output in the text file you specify, while wscript will display a popup box.

Second, "//E:VBScript" seems to be optional. I haven't seen any difference when I use this command or when I don't.

Third, the "//NoLogo" option makes sure that you get only the output from your program, and not added displays provided by cscript.exe. (Leave this out and see what happens!)

Finally, specify your output file. If you use one ">", then your output will always override an existing file. If you use two ">>", then your output will apend to the text file.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top