Advertisement
aveyo

netmon

Mar 18th, 2020
1,757
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.79 KB | None | 0 0
  1. <# :: netmon.bat - a network speed monitor directly on the taskbar (changes title every second)
  2. @echo off&set "0=%~f0"
  3. reg query HKU\S-1-5-19>nul 2>nul||(powershell -nop -c start $env:0 -v runas -win 2&exit)
  4. powershell -nop -noni -c iex(gc $env:0 -deli "`0")&exit
  5. #>
  6.  
  7. $unit=1MB
  8. #$unit=1KB #uncomment to measure in KiloBytes/second
  9.  
  10. $ErrorActionPreference=0
  11. gwmi win32_networkadapter -filter "netconnectionstatus=2" |% {
  12.   $r='"\Network Interface('+$_.name+')\Bytes Received/sec"';
  13.   $s='"\Network Interface('+$_.name+')\Bytes Sent/sec"'
  14. }
  15. typeperf $r $s -y |% {
  16.   $a=$_ -split '"'; $dl=($a[3]/$unit).tostring('0.000').padright(9,'0'); $up=($a[5]/$unit).tostring('0.000').padright(9,'0')
  17.   $host.ui.RawUI.WindowTitle="$dl / $up"
  18.   if ($host.UI.RawUI.WindowSize.Height -gt 1) {mode 50,1}
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement