PDA

View Full Version : Fun with scripts



OC
09-08-2004, 03:30 PM
Const ForReading = 1

On Error Resume Next
strInputFile = "C:\ComputerList.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set LogFile = fso.createtextfile("c:\BadPCNames.txt")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(strInputFile, ForReading)
arrComputers = Split(objTextStream.ReadAll, vbCrLf)
objTextStream.Close

For Each strComputer In arrComputers

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
If Err.Number <> 0 Then
logfile.writeline strComputer
Err.Clear
End If

Next