Juzzz Posted May 30, 2009 Posted May 30, 2009 i know how to get m ipaddress (@IPAddress1) but how do i get the information: subnetmask, gateway, primary DNS, Alternative DNS, wins, etc from all my adapters? I know how to get my adapter names so if i need that its no problem. does anyone know how to get these?
DCCD Posted May 30, 2009 Posted May 30, 2009 Command Line RunWait('"' & @ComSpec & '" /c ipconfig/all >>config.log', '', @SW_HIDE) Run("NOTEPAD.EXE config.log") [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
Juzzz Posted May 31, 2009 Author Posted May 31, 2009 Command Line RunWait('"' & @ComSpec & '" /c ipconfig/all >>config.log', '', @SW_HIDE) Run("NOTEPAD.EXE config.log") i need them in an var not just see it true notepad
DCCD Posted May 31, 2009 Posted May 31, 2009 (edited) i don't know what you want, but play with this, I think you'll find the correct way! RunWait('"' & @ComSpec & '" /c ipconfig/all >>config.log', '', @SW_HIDE) $f = FileOpen("config.log", 0) While 1 $a = FileRead ($f) If $a Then MsgBox(0,"",$a&@CRLF) FileClose($f) FileDelete("config.log") EndIf Exit WEnd . Edited May 31, 2009 by DCCD [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
James Posted May 31, 2009 Posted May 31, 2009 Really bad, and I only suggest if it's the last method. I've only done two for you, because I don't have time. #include <File.au3> #include <Array.au3> Dim $hArray RunWait('"' & @ComSpec & '" /c ipconfig/all >>config.log', '', @SW_HIDE) _FileReadToArray("config.log", $hArray) _ArrayDisplay($hArray) MsgBox(0, "", _Subnet($hArray[28])) MsgBox(0, "", _Gateway($hArray[31])) Func _Subnet($hSubMask) $hRet = StringRight($hSubMask, 13) Return $hRet EndFunc ;==>_Subnet Func _Gateway($hGateway) $hRet = StringRight($hGateway, 11) Return $hRet EndFunc ;==>_Gateway Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
ProgAndy Posted May 31, 2009 Posted May 31, 2009 Here i wrote some code to get some information about the networkadapters (the XML-idea i took from Gordon J. Tyler and this post)GetAdaptersXML.au3 *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
rajeshontheweb Posted June 1, 2009 Posted June 1, 2009 (edited) expandcollapse popup#include <array.au3> $adapterInfo = _WMI_Win32_NetworkAdapterConfiguration() _ArrayDisplay($adapterInfo) ; Generated by AutoIt Scriptomatic June 01, 2009 Func _WMI_Win32_NetworkAdapterConfiguration($AdapterName = "") ; Rajesh V R ; v 1.0 01 June 2009 ; use the adapter name as seen in the network connections dialog... Const $wbemFlagReturnImmediately = 0x10 Const $wbemFlagForwardOnly = 0x20 Local $colNICs="", $NIC, $strQuery, $objWMIService $strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration" $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2") $colNICs = $objWMIService.ExecQuery($strQuery, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) Local $retVal[1][1], $r, $c Local $output If IsObj($colNICs) Then For $NIC In $colNICs $r = UBound($retVal, 1) ReDim $retVal[$r + 1][61] $retVal[$r - 1][1] = $NIC.ArpAlwaysSourceRoute $retVal[$r - 1][2] = $NIC.ArpUseEtherSNAP $retVal[$r - 1][3] = $NIC.Caption $retVal[$r - 1][4] = $NIC.DatabasePath $retVal[$r - 1][5] = $NIC.DeadGWDetectEnabled $retVal[$r - 1][6] = $NIC.DefaultIPGateway(0) $retVal[$r - 1][7] = $NIC.DefaultTOS $retVal[$r - 1][8] = $NIC.DefaultTTL $retVal[$r - 1][9] = $NIC.Description $retVal[$r - 1][10] = $NIC.DHCPEnabled $retVal[$r - 1][11] = WMIDateStringToDate($NIC.DHCPLeaseExpires) $retVal[$r - 1][12] = WMIDateStringToDate($NIC.DHCPLeaseObtained) $retVal[$r - 1][13] = $NIC.DHCPServer $retVal[$r - 1][14] = $NIC.DNSDomain $retVal[$r - 1][16] = $NIC.DNSEnabledForWINSResolution $retVal[$r - 1][17] = $NIC.DNSHostName $retVal[$r - 1][18] = $NIC.DNSServerSearchOrder(0) $retVal[$r - 1][19] = $NIC.DomainDNSRegistrationEnabled $retVal[$r - 1][20] = $NIC.ForwardBufferMemory $retVal[$r - 1][21] = $NIC.FullDNSRegistrationEnabled $retVal[$r - 1][22] = $NIC.GatewayCostMetric(0) $retVal[$r - 1][23] = $NIC.IGMPLevel $retVal[$r - 1][24] = $NIC.Index $retVal[$r - 1][25] = $NIC.IPAddress(0) $retVal[$r - 1][26] = $NIC.IPConnectionMetric $retVal[$r - 1][27] = $NIC.IPEnabled $retVal[$r - 1][28] = $NIC.IPFilterSecurityEnabled $retVal[$r - 1][29] = $NIC.IPPortSecurityEnabled $retVal[$r - 1][30] = $NIC.IPSecPermitIPProtocols(0) $retVal[$r - 1][31] = $NIC.IPSecPermitTCPPorts(0) $retVal[$r - 1][32] = $NIC.IPSecPermitUDPPorts(0) $retVal[$r - 1][33] = $NIC.IPSubnet(0) $retVal[$r - 1][34] = $NIC.IPUseZeroBroadcast $retVal[$r - 1][35] = $NIC.IPXAddress $retVal[$r - 1][36] = $NIC.IPXEnabled $retVal[$r - 1][37] = $NIC.IPXFrameType(0) $retVal[$r - 1][38] = $NIC.IPXMediaType $retVal[$r - 1][39] = $NIC.IPXNetworkNumber(0) $retVal[$r - 1][40] = $NIC.IPXVirtualNetNumber $retVal[$r - 1][41] = $NIC.KeepAliveInterval $retVal[$r - 1][42] = $NIC.KeepAliveTime $retVal[$r - 1][43] = $NIC.MACAddress $retVal[$r - 1][44] = $NIC.MTU $retVal[$r - 1][45] = $NIC.NumForwardPackets $retVal[$r - 1][46] = $NIC.PMTUBHDetectEnabled $retVal[$r - 1][47] = $NIC.PMTUDiscoveryEnabled $retVal[$r - 1][48] = $NIC.ServiceName $retVal[$r - 1][49] = $NIC.SettingID $retVal[$r - 1][50] = $NIC.TcpipNetbiosOptions $retVal[$r - 1][51] = $NIC.TcpMaxConnectRetransmissions $retVal[$r - 1][52] = $NIC.TcpMaxDataRetransmissions $retVal[$r - 1][53] = $NIC.TcpNumConnections $retVal[$r - 1][54] = $NIC.TcpUseRFC1122UrgentPointer $retVal[$r - 1][55] = $NIC.TcpWindowSize $retVal[$r - 1][56] = $NIC.WINSEnableLMHostsLookup $retVal[$r - 1][57] = $NIC.WINSHostLookupFile $retVal[$r - 1][58] = $NIC.WINSPrimaryServer $retVal[$r - 1][59] = $NIC.WINSScopeID $retVal[$r - 1][60] = $NIC.WINSSecondaryServer Next ReDim $retVal[UBound($retVal,1)-1][61] ; remove the last blank row ... Else SetError(-1, "No WMI Objects Found for class: Win32_NetworkAdapterConfiguration", "") EndIf $objWMIService = "" $colNICs = "" $NIC = "" Return $retVal EndFunc ;==>_WMI_Win32_NetworkAdapterConfiguration 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)) EndFunc ;==>WMIDateStringToDate Edited June 1, 2009 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet
rajeshontheweb Posted June 1, 2009 Posted June 1, 2009 later on i will check try to modify it to use the adapter name as from the network connections, at the moment it will return all the adapters' full information, use the one u need, viz., to get IP and MACAddress of first adapter use $adapterInfo = _WMI_Win32_NetworkAdapterConfiguration() $strMACAddress = $adapterInfo[0][43] $strIPAddress = $adapterInfo[0][25] Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet
Juzzz Posted June 1, 2009 Author Posted June 1, 2009 later on i will check try to modify it to use the adapter name as from the network connections, at the moment it will return all the adapters' full information, use the one u need, viz., to get IP and MACAddress of first adapter use $adapterInfo = _WMI_Win32_NetworkAdapterConfiguration() $strMACAddress = $adapterInfo[0][43] $strIPAddress = $adapterInfo[0][25] thats a pretty nice code you got there. i found the plays of the reg key like: ;check the right ID's $Reg_Adapters_ID = "{4D36E972-E325-11CE-BFC1-08002BE10318}" $ID_NIC1 = "{3366A0CF-A7E6-4B92-AC4C-9CD360CD5FB9}" $ID_NIC2 = "{63232284-6CC4-4007-B612-AFEF8614E4D7}" ;Get NIC names $Name_NIC1 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\" & $Reg_Adapters_ID & "\" & $ID_NIC1 & "\Connection", "Name") $Name_NIC2 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\" & $Reg_Adapters_ID & "\" & $ID_NIC2 & "\Connection", "Name") $DHCP_IP_NIC1 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & $ID_NIC1 & "\Parameters\Tcpip", "DhcpIPAddress") but i think al the ID's etc are different, but i see an iD in your output from your code.. maby i can get that
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now