Ok, one more silver platter \:\)

Personally I do not like RedirectOutput so much.
I’d go for the Open, Writeline, Close option.

 Code:
Break on

$rc = Open(1, @SCRIPTDIR + "\hardware.txt", 5)

$wmiColl1 = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_ComputerSystem ")
$wmiColl2 = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_BIOS ")

For Each $wmiObj in $wmiColl1
	$rc = WriteLine(1, "Manufacturer: " + $wmiObj.Manufacturer + @CRLF)
	$rc = WriteLine(1, "Model: " + $wmiObj.Model + @CRLF )
	$rc = WriteLine(1, "Currently logged on user: " + $wmiObj.UserName + @CRLF )
Next

For Each $wmiObj in $wmiColl2
	$rc = WriteLine(1, "Service tag:" + Trim($wmiObj.SerialNumber) + @CRLF)
Next

$rc = Close(1)


This will give you issues when the next pc is writing to the file because you will not know who wrote what. Adding the system name would fix that or even create separate files for each computer. If this runs during logon the separate files option would be best imho because it will prevent issues with the file being locked for writing by system1 when system2 want to write his data.


Edited by Mart (2009-02-25 01:35 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.