Output script results to text file
Posted on 2004-10-27
I'm not a big vbscript guy, so I'm not sure what I'm doing here. I have a vb script (a .vbs file on my pc) running this script to get the serial # of the pc:
On Error Resume Next
StrComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem in colItems
Wscript.echo "SerialNumber: " & objItem.SerialNumber
However, this just outputs the serial # to the screen. I need to put these serial numbers into a text file. So I added some lines to do this:
Open ("C:\results.txt") For Output As #1
Write #1, "SerialNumber: " & objItem.SerialNumber
But I keep getting an error: Expected End of Statement on the Open line right at the "For" part.
Am I doing this right? I'm sure it's just something stupid I'm doing, any help is appreciated, thanks!