Re: Writing to a text file



Also, you can probably run your existing script at a command prompt with the
cscript host and redirect the output to a text file. For example, if the
VBScript program is in a file called ChangePW.vbs, the following command
will create the text file report.text:

cscript //nologo ChangePW.vbs > report.txt

the "//nologo" parameter suppresses WSH logo info. The above assumes you are
in the directory where the VBScript file is saved. Otherwise you must
specify the full path. The text file is created in the current directory,
unless you specify a path.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

"Pegasus (MVP)" <I.can@xxxxxxxxxx> wrote in message
news:OLjqC1MdIHA.5160@xxxxxxxxxxxxxxxxxxxxxxx
The line

wscript.echo objExec.StdOut.Readline

writes a line of text to the screen. As I said before, you
must replace it with a statement that writes your data to
a file. The link I gave you has numerous examples for
doing this, as has the downloadable help file script56.chm.


"Joe H" <JoeH@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2251DD31-252A-4051-A346-D35B73D2C7AF@xxxxxxxxxxxxxxxx
what is the line statement to replace "wscript.echo",to make the script
to
write to file
--
Joe H


"Pegasus (MVP)" wrote:


"Joe H" <JoeH@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:304F851C-31F0-456E-80D7-EEB62D8E140D@xxxxxxxxxxxxxxxx
With help from the MVP in this forum, I have a script that resets the
local
admin passwords in different OU in my network.

I have figure out a way to make the script print the computer name on
the
screen. This works great. Now I want to get fancier and want to print
what
I
get on the screen to a text file.

How do I make a script save to a text file in the c drive on my
server?

Thanks,

--
Joe H

Have a look here:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0914.mspx

The article suggests you use code like this to pick up screen output:
Set objShell = CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec _
("%comspec% /c ping -n 3 -w 1000 192.168.1.1")
Do While Not objExecObject.StdOut.AtEndOfStream
wscript.echo objExecObject.StdOut.ReadAll()
Loop

Instead of using "wscript.echo", write your lines to a text file.
You might also want to download the whole Scripting Guy file -
there is a wealth of information in there!







.



Relevant Pages

  • Re: & Now, a Script to List the Running Process Info - Re: Useful little Script to Show the
    ... Done that to the desktop folder, ... at a Command Prompt, with the Name of the Script File (after a Space, ... a Folder where the Command Prompt Opens (either the Root of the ...
    (uk.people.silversurfers)
  • Re: Finding members of RDP groups of a list of computers
    ... got the script to work by double clicking the vbs file. ... cscript //nologo RDPMembers.vbs> report.txt from the command prompt? ... MVP Directory Services ... Your text file of computer names must be located in a folder on ...
    (microsoft.public.scripting.vbscript)
  • Re: Fully Disable Command Prompt
    ... I found if I disable the command prompt script ... As for ntfs permissions, hows this for an odd one. ... >as in the dllcache folder or service pack files folder. ...
    (microsoft.public.win2000.security)
  • Re: export account details from an OU
    ... The script can be run on any computer authenticated to the domain. ... I would run it at a command prompt with the cscript host. ... Const ADS_SCOPE_SUBTREE = 2 ... Set objConnection = CreateObject ...
    (microsoft.public.windows.server.active_directory)
  • Re: Perl vs. W2000
    ... >default to the test directory on c: via the command prompt (e.g., ... in a perl script it is normal to have the first line start with: ... >different from where the script resides, ...
    (microsoft.public.win2000.general)