I am querying WMI for current throughput of my NIC adapters.. Basically looking to make a lite, compiled (.exe) network monitor for WinPE3x (Win7 PE).. I intend on using this monitor during an MDT or SCCM deployment to ensure traffic is being moved at an adequate speed.
Problem:
1. I can not verify that the pulled object is valid, IsObject ALWAYs returns a "True" even if the Query results are empty.
2. Can not use ".count" property listed in the Win32_Class in on ms's site.
Any Help towards this project is much appreciated !
*FYI: I also want to make a similar monitor for transfer via USB.
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=C:\support\script\network-icons\icons\Network ID SH.ico
#AutoIt3Wrapper_outfile=display-net-traffic.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Local $wbemFlagReturnImmediately= 0x10
Local $wbemFlagForwardOnly = 0x20
Local $h_wbemFlags = $wbemFlagReturnImmediately + $wbemFlagForwardOnly
$s_ComputerName = "localhost"
$o_WMIService = ObjGet("winmgmts:\\" & $s_ComputerName & "\root\CIMV2")
SplashTextOn("Network Traffic Monitor","Network Traffic Monitor",300,100,0,0,9,"arial",10,600)
For $i = 0 To 1000
$o_NetTraffic = $o_WMIService.ExecQuery("SELECT NAME, BytesReceivedPersec, BytesSentPersec FROM Win32_PerfFormattedData_Tcpip_NetworkInterface WHERE Name LIKE '%Network%'", "WQL", $h_wbemFlags)
If IsObj($o_NetTraffic) Then
For $o_item in $o_NetTraffic
Round(FileGetSize("C:\Windows\UNSIPPS.exe")/1048576,2)
$message = StringStripWS ( $o_item.Name, 3 ) & @CRLF & @CRLF & _
Round($o_item.BytesReceivedPersec/1048576,2) & " MB/sec rece" & @CRLF & _
Round($o_item.BytesSentPersec/1048576,2) & " MB/sec sent"
ControlSetText("Network Traffic Monitor","","Static1", $message)
Sleep(1000)
Next
;Else
; ControlSetText("Network Traffic Monitor","","Static1", "No Module Found...")
; Sleep(5000)
; ExitLoop
Else
ControlSetText("Network Traffic Monitor","","Static1", "Object doesn't exist? ..")
Sleep(5000)
EndIf
Next