Discussion:
Is this possible?
(too old to reply)
Aaron-McLeod
2006-11-08 16:12:58 UTC
Permalink
Hello,

I would like to concoct a VB script that will query Name, Model, and
TotalPhysicalMemory from Win32_ComputerSystem and save the results into a
text file I can view from a network share. I have created the WMI query,
but cannot figure out the best way to view the results, or redirect the
output into a text file. Any help is greatly appreciated, as I'm sure there
is something simple I don't understand.
Armin Linder
2006-11-08 17:05:43 UTC
Permalink
2 ways:

use wscript.echo commands in your script to write the results to the
console:

....
wScript.Echo objComputer.TotalPhysicaslMemory

and run

cscript //nologo myscript.vbs

to see the results on screen, or

cscript //nologo myscript.vbs >\\myserver\myshare\%computername%.log

to create a log file named like the computer on the server myserver in
the share myshare.

-or-

Look at the Scripting.FileSystemObject's CreateTextFile and Writeline
methods:

Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
MyFile.WriteLine("This is a test.")
MyFile.Close

You may, instead of c:\testfile.txt use a UNC name like
\\myserver\myshare\testfile.txt, so you do not have to write to a
specific network drive, which, of course, is also an option, if you can
assure that the network drive is connected when your script runs,

...Armin

Loading...