Jump to content

all about my NICs , connections and so on


oneLess
 Share

Recommended Posts

an array with all data about my NICs.

based on WMI , registry

and only the active PPPoE connection name i get it from ipconfig/all output.

[cant find for now other way...!?] maybe you can help here.

first line [1] is for @IPaddress1

[$PPPoE] line is for active PPPoE

returned parameters that can be found in my array :

Global $_net_isok = 0 ; [-1=Yes , 0=No] ; is not ok for [re]moved nics or other software components reported by WMI , for active PPPoE [created later as entry in my array]

Global $_net_guid = 1 ; [string] ; NIC's registry GUID

Global $_net_conn = 2 ; [string] ; connection name

Global $_net_name = 3 ; [string] ; product name

Global $_net_dhcp = 4 ; [-1=enabled , 0=disabled] ; dhcp status

Global $_net_ip__ = 5 ; [string] ; IP

Global $_net_stat = 6 ; [0..12] ; WMI status [2=Connected, 7=Media disconnected] ; -> this two work

; 0=Disconnected, 1=Connecting, 2=Connected, 3=Disconnecting, 4=Hardware not present, 5=Hardware disabled, 6=Hardware malfunction

; 7=Media disconnected, 8=Authenticating, 9=Authentication succeeded, 10=Authentication failed, 11=Invalid address, 12=Credentials required

Global $_net_mask = 7 ; [string] ; subnet mask

Global $_net_gate = 8 ; [string] ; gateway

Global $_net_dns_ = 9 ; [string] ; DNS

Global $_net_mac_ = 10 ; [string] ; MAC address

Global $_net_indx = 11 ; [1..how many they are] ; WMI index

Global $_net_ipAd = 12 ; [1,2,3 or 4] ; if IP is @IPAddress1,2,3 or 4

Global $_net_pppo = 13 ; [-1=Yes , 0=No] ; is PPPoE connection

Global $_net_RASa = 14 ; [-1=Yes , 0=No] ; RAS is active

Global $_net_RASd = 15 ; [-1=Yes , 0=No] ; RAS is default

sample for use the array :

$_net_nics [1][$_net_conn]

; ----> will return the connection name for the NIC who have IP=@IPaddress1

$_net_nics [1][$_net_mac_]

; ----> will return the MAC for the NIC who have IP=@IPaddress1

and so on...

If $PPPoE <> 0 Then ...... $_net_nics [$PPPoE][$_net_conn]

; ----> will return the connection name for PPPoE ; [if exist an active one]

i tested this only for integrated or PCI nics with or w/o PPPoE

i dont know if is working for other like wireless or VPN or...

can you report back this ?

use the attached 3c_networKer.au3 with

;----------------------------------------------------------------------------
    #include <Constants.au3>
    #include <3c_networKer.au3>
    #include <File.au3>             #include <Array.au3>
;----------------------------------------------------------------------------
    _display_my_nics_array ( ); <------------------------- I DO NOT USE , is included in my main script [just for dispaying] 
;----------------------------------------------------------------------------
    Func _display_my_nics_array ( )
        $_txt = "my active connection is [" & $_net_nics [1][$_net_conn] & "]"  ; [1] is @IPAddress1
        If $PPPoE <> 0 Then $_txt = $_txt & @CRLF & "[" & $_net_nics [$PPPoE][$_net_conn] & "] is my active PPPoE connection name ."
        MsgBox (64, "   active connection[s] :   " ,  $_txt ) 
        
        _ArrayDisplay ( $_net_nics , "oneLess NICs" )
    EndFunc
;----------------------------------------------------------------------------

3c_networKer.au3

Edited by oneLess
Link to comment
Share on other sites

  • 9 months later...
  • 3 months later...

This works great in XP, but under Vista adapers are not detected if they are not plugged or connected. I am trying to disable Wireless NICs as people connect to the VPN and I can do this with this and another bit of code I borrowed, but on vista it does not detect the adapter unless it's connected. Any thoughts?

Great work all in all!

Link to comment
Share on other sites

I use this for my personal use :

Func _GetNICList()
    Local $wbemFlagReturnImmediately = 0x10
    Local $wbemFlagForwardOnly = 0x20
    Local $colItems = ''
    Local $Output = ''
    Local $NBList = 1
    Local $aNICList[$NBList][3]
    $aNICList[0][0] = "Name"
    $aNICList[0][1] = "State"
    $aNICList[0][2] = "PNPDeviceID"

    $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

; #####################################################################
; List Of Object for Win32_NetworkAdapter :
; AdapterType               : $objItem.AdapterType
; AdapterTypeId             : $objItem.AdapterTypeId
; AutoSense                 : $objItem.AutoSense
; Availability              : $objItem.Availability
; Caption                   : $objItem.Caption
; ConfigManagerErrorCode    : $objItem.ConfigManagerErrorCode
; ConfigManagerUserConfig   : $objItem.ConfigManagerUserConfig
; CreationClassName         : $objItem.CreationClassName
; Description               : $objItem.Description
; DeviceID                  : $objItem.DeviceID
; ErrorCleared              : $objItem.ErrorCleared
; ErrorDescription          : $objItem.ErrorDescription
; Index                     : $objItem.Index
; InstallDate               : WMIDateStringToDate($objItem.InstallDate)
; Installed                 : $objItem.Installed
; LastErrorCode             : $objItem.LastErrorCode
; MACAddress                : $objItem.MACAddress
; Manufacturer              : $objItem.Manufacturer
; MaxNumberControlled       : $objItem.MaxNumberControlled
; MaxSpeed                  : $objItem.MaxSpeed
; Name                      : $objItem.Name
; NetConnectionID           : $objItem.NetConnectionID
; NetConnectionStatus       : $objItem.NetConnectionStatus
; $objItem.NetworkAddresses(0)
; NetworkAddresses          : $strNetworkAddresses
; PermanentAddress          : $objItem.PermanentAddress
; PNPDeviceID               : $objItem.PNPDeviceID
; $objItem.PowerManagementCapabilities(0)
; PowerManagementCapabilities   : $strPowerManagementCapabilities
; PowerManagementSupported  : $objItem.PowerManagementSupported
; ProductName               : $objItem.ProductName
; ServiceName               : $objItem.ServiceName
; Speed                     : $objItem.Speed
; Status                    : $objItem.Status
; StatusInfo                : $objItem.StatusInfo
; SystemCreationClassName   : $objItem.SystemCreationClassName
; SystemName                : $objItem.SystemName
; #####################################################################


    If IsObj($colItems) Then
        For $objItem In $colItems
            $PNPDev = $objItem.PNPDeviceID
            If StringLeft($PNPDev, 3) = "PCI" Or StringLeft($PNPDev, 3) = "USB" Then
                ReDim $aNICList[$NBList + 1][3]
                $aNICList[$NBList][0] = $objItem.Name
                $aNICList[$NBList][1] = $objItem.NetConnectionStatus
                $aNICList[$NBList][2] = $objItem.PNPDeviceID
                $NBList += 1
            EndIf
        Next
    Else
        SetError(1)
        $aNICList = ''
    EndIf
        Return $aNICList
EndFunc  ;==>_GetNICList

This code function on Windows XP and Windows Vista.

The line

If StringLeft($PNPDev, 3) = "PCI" Or StringLeft($PNPDev, 3) = "USB" Then
give me only PCI and USB network cards.

The commanted lines can give you other informations.

Best Regards.Thierry

Link to comment
Share on other sites

  • 9 months later...

This script does not work at all.

H:\AutoIt3\Include\3c_networKer.au3 (213) : ==> Array variable subscript badly formatted.:

$_net_nics [$_IP_to_move][$_jj] = $_net_nics [$_IP_from_move][$_jj]

$_net_nics [$_IP_to_move][$_jj] = $_net_nics [^ ERROR

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...