hannable80
Technical User
Hi all,
Thanks for the help last time now i must ask for it again.
Can any one tell me where im going wrong trying to access the a string to use a statement to grab the mac address of a pc. keep getting an error.
Cheers
Dim objShell, strComputer, strInput
Dim strPing
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\computerlist.txt", ForReading)
Const ForReading = 1
Const ForAppending = 8
Dim arrFileLines()
i = 0
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("c:\output.txt") Then
Else
Set objFile = objFSO.CreateTextFile("c:\output.txt")
End If
set objFile = nothing
Set objFile = objFSO.OpenTextFile("c:\output.txt", ForAppending)
For Each strLine in arrFileLines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& strLine & "'")
Set objMac = ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where objStatus.StatusCode=<>1)
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
objFile.WriteLine("Computer " & strLine & " is not reachable" & vbTab & objStatus.ProtocolAddress)
Else
objFile.WriteLine("Computer " & strLine & " is reachable *********************"& vbTab & objStatus.ProtocolAddress&
End If
Next
Next
objFile.Close
Thanks for the help last time now i must ask for it again.
Can any one tell me where im going wrong trying to access the a string to use a statement to grab the mac address of a pc. keep getting an error.
Cheers
Dim objShell, strComputer, strInput
Dim strPing
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\computerlist.txt", ForReading)
Const ForReading = 1
Const ForAppending = 8
Dim arrFileLines()
i = 0
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("c:\output.txt") Then
Else
Set objFile = objFSO.CreateTextFile("c:\output.txt")
End If
set objFile = nothing
Set objFile = objFSO.OpenTextFile("c:\output.txt", ForAppending)
For Each strLine in arrFileLines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& strLine & "'")
Set objMac = ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where objStatus.StatusCode=<>1)
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
objFile.WriteLine("Computer " & strLine & " is not reachable" & vbTab & objStatus.ProtocolAddress)
Else
objFile.WriteLine("Computer " & strLine & " is reachable *********************"& vbTab & objStatus.ProtocolAddress&
End If
Next
Next
objFile.Close