Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for login_log_ip_mac.vbs

(view source code of login_log_ip_mac.vbs as plain text)

  1. ' Query all network adapters that have a MAC address
  2. strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress > ''"
  3. Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
  4. Set colItems      = objWMIService.ExecQuery( strQuery, "WQL", 48 )
  5. For Each objItem In colItems
  6. 	If IsArray( objItem.IPAddress ) Then
  7. 		strIP  = strIP  & ";" & Join( objItem.IPAddress, ";" )
  8. 		strMAC = strMAC & ";" & Replace( objItem.MACAddress, ":", "" )
  9. 	End If
  10. Next
  11. Set colItems      = Nothing
  12. Set objWMIService = Nothing
  13. ' Log the result
  14. Set objFSO = CreateObject( "Scripting.FileSystemObject" )
  15. Set objLog = objFSO.OpenTextFile( strLog, ForAppending, True, TristateFalse )
  16. objLog.WriteLine Mid( strIP, 2 ) & "," & Mid( strMAC, 2 )
  17. objLog.Close
  18. Set objLog = Nothing
  19. Set objFSO = Nothing

page last uploaded: 2021-01-27, 16:12