$obj = ObjGet("WinMgmts:\\.\root\cimv2")
$que=$obj.ExecQuery("Select * from Win32_NetworkAdapterConfiguration")
$res=''
For $o in $que
$res&=$o.ArpAlwaysSourceRoute&@CRLF & _
$o.ArpUseEtherSNAP&@CRLF & _
$o.DeadGWDetectEnabled&@CRLF & _
$o.DefaultIPGateway&@CRLF & _
$o.DefaultTOS&@CRLF & _
$o.DefaultTTL&@CRLF & _
$o.Description&@CRLF & _
$o.DHCPEnabled&@CRLF & _
$o.DHCPLeaseExpires&@CRLF & _
$o.DHCPLeaseObtained&@CRLF & _
$o.DHCPServer&@CRLF & _
$o.DNSDomain&@CRLF & _
$o.DNSDomainSuffixSearchOrder&@CRLF & _
$o.DNSEnabledForWINSResolution&@CRLF & _
$o.DNSHostName&@CRLF & _
$o.DNSServerSearchOrder&@CRLF & _
$o.DomainDNSRegistrationEnabled&@CRLF & _
$o.ForwardBufferMemory&@CRLF & _
$o.FullDNSRegistrationEnabled&@CRLF & _
$o.GatewayCostMetric&@CRLF & _
$o.IGMPLevel&@CRLF & _
$o.Index&@CRLF & _
$o.IPAddress&@CRLF & _
$o.IPConnectionMetric&@CRLF & _
$o.IPEnabled&@CRLF & _
$o.IPFilterSecurityEnabled&@CRLF & _
$o.IPPortSecurityEnabled&@CRLF & _
$o.IPSecPermitIPProtocols&@CRLF & _
$o.IPSecPermitTCPPorts&@CRLF & _
$o.IPSecPermitUDPPorts&@CRLF & _
$o.IPSubnet&@CRLF & _
$o.IPUseZeroBroadcast&@CRLF & _
$o.IPXAddress&@CRLF & _
$o.IPXEnabled&@CRLF & _
$o.IPXFrameType&@CRLF & _
$o.IPXMediaType&@CRLF & _
$o.IPXNetworkNumber&@CRLF & _
$o.IPXVirtualNetNumber&@CRLF & _
$o.KeepAliveInterval&@CRLF & _
$o.KeepAliveTime&@CRLF & _
$o.MACAddress&@CRLF & _
$o.MTU&@CRLF & _
$o.NumForwardPackets&@CRLF & _
$o.PMTUBHDetectEnabled&@CRLF & _
$o.PMTUDiscoveryEnabled&@CRLF & _
$o.ServiceName&@CRLF & _
$o.SettingID&@CRLF & _
$o.TcpipNetbiosOptions&@CRLF & _
$o.TcpMaxConnectRetransmissions&@CRLF & _
$o.TcpMaxDataRetransmissions&@CRLF & _
$o.TcpNumConnections&@CRLF & _
$o.TcpUseRFC1122UrgentPointer&@CRLF & _
$o.TcpWindowSize&@CRLF & _
$o.WINSEnableLMHostsLookup&@CRLF & _
$o.WINSHostLookupFile&@CRLF & _
$o.WINSPrimaryServer&@CRLF & _
$o.WINSScopeID&@CRLF & _
$o.WINSSecondaryServer&@CRLF&@CRLF
Next
FileWrite(@ScriptDir&'\123',$res)
НетуСмотри wmic.exe в папке windows\system32\wbem
Этот файл приложи.
$obj = ObjGet("WinMgmts:\\.\root\cimv2")
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
fu1(11)
fu1(13)
fu1(25)
Func fu1($num)
$que=$obj.get("Win32_NetworkAdapterConfiguration.index="&$num&"")
Local $ip,$gat,$mask,$dns
For $o In $que.ipaddress
$ip&=$o&@CRLF
Next
For $o In $que.DefaultIPGateway
$gat&=$o&@CRLF
Next
For $o In $que.IPSubnet
$mask&=$o&@CRLF
Next
For $o In $que.DNSServerSearchOrder
$dns&=$o&@CRLF
Next
;~ MsgBox(0,'','ip='&$ip&@CRLF&'mask='&$mask&@CRLF&'gathway='&$gat&@CRLF&'dns='&$dns)
FileWrite(@ScriptDir&'\1653','ip='&$ip&@CRLF&'mask='&$mask&@CRLF&'gathway='&$gat&@CRLF&'dns='&$dns&@CRLF)
EndFunc
$oMyError=0
Func MyErrFunc()
EndFunc ;==>MyErrFunc
Разрешение экрана: 1024x600:32что за os у тебя
$n = 1
While 1
Sleep(100)
$var1 = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards", $n)
If @error <> 0 Then ExitLoop
$var2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"&$var1, "ServiceName")
$Description = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"&$var1, "Description")
$IP = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"&$var2, "IPAddress")
$Gateway = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"&$var2, "DefaultGateway")
$DNS= RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"&$var2, "NameServer")
$Mask= RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"&$var2, "SubnetMask")
$n = $n + 1
MsgBox(0, $Description, "IP: " & $IP & " | Gateway: " & $Gateway & " | DNS: " & $DNS & " | Mask: " & $Mask)
WEnd
$obj = ObjGet("WinMgmts:\\.\root\cimv2")
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$q=$obj.ExecQuery('Select * from Win32_NetworkAdapterConfiguration where ipenabled="true"')
Local $ip,$gat,$mask,$dns,$ind
For $que In $q
For $o In $que.ipaddress
$ip&=$o&@CRLF
Next
For $o In $que.DefaultIPGateway
$gat&=$o&@CRLF
Next
For $o In $que.IPSubnet
$mask&=$o&@CRLF
Next
For $o In $que.DNSServerSearchOrder
$dns&=$o&@CRLF
Next
$ind&=$que.index&@CRLF
Next
ClipPut('ip='&$ip&@CRLF&'mask='&$mask&@CRLF&'gathway='&$gat&@CRLF&'dns='&$dns&@CRLF&$ind)
$oMyError=0
Func MyErrFunc()
EndFunc ;==>MyErrFunc
Не подходитЕще вариант, правда без парсинга и без отображенияимени сетевого подключения.
Результат пишеться в буфер обмена.
ip=0.0.0.0
192.168.1.251
192.168.56.1
mask=
255.255.255.0
255.255.255.0
gathway=192.168.1.1
dns=192.168.1.1
8.8.8.8
192.168.1.1
11
13
25
#include 'encoding.au3';есть где-то у нас на форуме.
$s_Read = ''
$i_PID = Run('netsh interface ip show config', '', @SW_HIDE, 6)
While 1
$s_Read &= StdoutRead($i_PID)
If @error Then ExitLoop
Sleep(1)
WEnd
$str=StringRegExp(_Encoding_866To1251($s_Read),'(?smi)Настройка интерфейса(.*?)\r\n\r\n',3)
$res=''
For $i=0 To UBound($str)-1
$str1=StringRegExp($str[$i],'(?smi)^(.*?)\r\n',3)
For $u=0 To UBound($str1)-1
If StringInStr($str1[$u],'"') Then
$res&=StringRegExpReplace($str1[$u],'^.*:\s+(\S+)','\1')&@CRLF
$u=$u+1
EndIf
If StringInStr($str1[$u],'IP') Then
$res&=StringRegExpReplace($str1[$u],'.*?:\s+(\S+).*','\1')&@CRLF
$u=$u+1
EndIf
If StringInStr($str1[$u],'Маска') Then
$res&=StringRegExpReplace($str1[$u],'.*?:\s+(\S+).*','\1')&@CRLF
$u=$u+1
EndIf
If StringInStr($str1[$u],'шлюз') Then
$res&=StringRegExpReplace($str1[$u],'.*?:\s+(\S+).*','\1')&@CRLF
$u=$u+1
EndIf
If StringInStr($str1[$u],'DNS') Then
$res&=StringRegExpReplace($str1[$u],'.*?:\s+(\S+).*','\1')&@CRLF
$u=$u+1
EndIf
Next
Next
MsgBox(0,'',$res)
$n = 1
While 1
Sleep(100)
$var1 = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards", $n)
If @error <> 0 Then ExitLoop
$var2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"&$var1, "ServiceName")
$Description = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"&$var1, "Description")
$NetName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\"&$var2&"\Connection", "Name")
$IP = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"&$var2, "IPAddress")
$Gateway = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"&$var2, "DefaultGateway")
$DNS= RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"&$var2, "NameServer")
$Mask= RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"&$var2, "SubnetMask")
$n = $n + 1
ConsoleWrite("Сетевое устройство: " & $Description & @CR)
ConsoleWrite("Имя сетевого подключения: " & $NetName & @CR)
ConsoleWrite("IP: " & $IP & @CR)
ConsoleWrite("Маска: " & $Mask & @CR)
ConsoleWrite("Шлюз: " & $Gateway & @CR)
ConsoleWrite("DNS: " & $DNS & @CR)
WEnd
А этот?
If StringInStr($str1[$u],'DNS') Then
$res&=StringRegExpReplace($str1[$u],'.*?:\s+(\d+.\d+.\d+.\d+).*','\1')&@CRLF
If Not StringInStr($str1[$u+1],'WINS') Then $res&=StringRegExpReplace($str1[$u+1],'\s+(\d+.\d+.\d+.\d+).*','\1')&@CRLF
$u=$u+1
EndIf
Func _getinfonet($getinfo)
$s_Read = ''
$i_PID = Run('netsh interface ip show config' & ' "' & $getinfo & '"', '', @SW_HIDE, 6)
While 1
$s_Read &= StdoutRead($i_PID)
If @error Then ExitLoop
Sleep(1)
WEnd
_GUICtrlIpAddress_ClearAddress($IPAddress1)
_GUICtrlIpAddress_ClearAddress($IPAddress2)
_GUICtrlIpAddress_ClearAddress($IPAddress3)
_GUICtrlIpAddress_ClearAddress($IPAddress4)
_GUICtrlIpAddress_ClearAddress($IPAddress5)
$str = StringRegExp(_Encoding_866To1251($s_Read), '(?smi)Настройка интерфейса(.*?)\r\n\r\n', 3)
$res = ''
For $i = 0 To UBound($str) - 1
$str1 = StringRegExp($str[$i], '(?smi)^(.*?)\r\n', 3)
For $u = 0 To UBound($str1) - 1
If StringInStr($str1[$u], '"') Then
$res = StringRegExpReplace($str1[$u], '^.*:\s+(\S+)', '\1')
$u = $u + 1
EndIf
If StringInStr($str1[$u], 'IP') Then
$res = StringRegExpReplace($str1[$u], '.*?:\s+(\S+).*', '\1') & @CRLF
$u = $u + 1
_GUICtrlIpAddress_Set($IPAddress1, $res)
EndIf
If StringInStr($str1[$u], 'Маска') Then
$res = StringRegExpReplace($str1[$u], '.*?:\s+(\S+).*', '\1') & @CRLF
$u = $u + 1
_GUICtrlIpAddress_Set($IPAddress2, $res)
EndIf
If StringInStr($str1[$u], 'шлюз') Then
$res = StringRegExpReplace($str1[$u], '.*?:\s+(\S+).*', '\1') & @CRLF
$u = $u + 1
_GUICtrlIpAddress_Set($IPAddress3, $res)
EndIf
If StringInStr($str1[$u], 'DNS') Then
$res = StringRegExpReplace($str1[$u], '.*?:\s+(\S+).*', '\1') & @CRLF
_GUICtrlIpAddress_Set($IPAddress4, $res)
$res = StringRegExpReplace($str1[$u], '.*?:\s+(\d+.\d+.\d+.\d+).*', '\1') & @CRLF
If Not StringInStr($str1[$u + 1], 'WINS') Then $res = StringRegExpReplace($str1[$u + 1], '\s+(\d+.\d+.\d+.\d+).*', '\1') & @CRLF
$u = $u + 1
_GUICtrlIpAddress_Set($IPAddress5, $res)
EndIf
Next
Next
EndFunc ;==>_getinfonet