Jump to content
Sign in to follow this  

Network Speed

Recommended Posts

I tried searching, but after looking thru 25 pages, I saw nothing on this topic.

I need to programmatically find out what the speed of network connections for local NICs are. I.E. one of the following: 10Mbps, 100Mbps or 1Gbps. I know the info is available since it is on the "Network Status" window that you get when doubleclicking on that network (when it is up) from the "Network Connections" window.

I have a kluge that reads the value off of the above window, but it fails when that link is down, and as a matter of fact will disable the link because when you call the shortcut for that network connection when it is down, it will disable it for some odd unknown but frustrating reason.

It is probably in some obscure dll or COM call, but after days of seaching, I cant find that, either. Perhaps I am just no good at searching! :D


Share this post

Link to post
Share on other sites

Found it after all (I think) in Scriptomatic. Under root\WMI there is a MSNdis_LinkSpeed property.

TraySetToolTip ('MSNdis_LinkSpeed')

const $wbemFlagReturnImmediately = 0x10
const $wbemFlagForwardOnly = 0x20
$colItems = ''
$strComputer = 'localhost'
$objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\root\WMI')
$colItems = $objWMIService.ExecQuery('SELECT * FROM MSNdis_LinkSpeed', 'WQL', _
        $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) Then
   For $objItem In $colItems
      $output&='Active:' & Not(Not($objItem.Active)) & @CRLF
      $output&='InstanceName:' & String($objItem.InstanceName) & @CRLF
      $output&='NdisLinkSpeed:' & $objItem.NdisLinkSpeed & @CRLF
      If Msgbox(1,'WMI Output',$Output) = 2 Then ExitLoop

Func WMIDateStringToDate($dtmDate)
  Return (StringMid($dtmDate, 5, 2) & '/' & _
    StringMid($dtmDate, 7, 2) & '/' & StringLeft($dtmDate, 4) _
    & ' ' & StringMid($dtmDate, 9, 2) & ':' & StringMid($dtmDate, 11, 2) & ':' & StringMid($dtmDate,13, 2))

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...