Alv. Posted January 24, 2006 Share Posted January 24, 2006 How I can get IP Gateway? Usualy I run commanline like this: ipconfig | find /i "192.168.100.254" and read %errorlevel% value. How I can run this comman by AutoIT? #Include <process.au3> $value=_RunDOS( "ipconfig | find /i "192.168.100.254"") doesn't work. Link to comment Share on other sites More sharing options...
w0uter Posted January 24, 2006 Share Posted January 24, 2006 (edited) i would run ipconfig with the std_out flag then use stringinstring for the ip then check @error Edited January 24, 2006 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
rudika Posted January 24, 2006 Share Posted January 24, 2006 i would run ipconfig with the std_out flagthen use stringinstring for the ipthen check @errorHey.Is it right, you don´t know your gateway that route your internet? Then you can use the tracert command with a url it will give out the used router. Pipe the issue in a file and read that part you need with the appropriate Autoif functions.a lot take place [font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font] Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 24, 2006 Share Posted January 24, 2006 How I can get IP Gateway? Usualy I run commanline like this: ipconfig | find /i "192.168.100.254" and read %errorlevel% value. How I can run this comman by AutoIT? #Include <process.au3> $value=_RunDOS( "ipconfig | find /i "192.168.100.254"") doesn't work. Somebody else may post a cool AutoIt function for this, but you can also use a batch file to run: @echo off REM GetGw.cmd batch file ipconfig | find "Gateway" > IpGw.txt for /f "tokens=2 delims=:" %%i in (IpGw.txt) do set IpGw=%%i echo %IpGw% > IpGw.txt Then just read the contents of IpGw.txt, but it will only show the gateway of the LAST instance if there are multiple NICs. You can also read it from the registry, though it's a small pain to get the NIC instance(s), and the value is different for DHCP or static. This is my idea: CODE ; Get IP Gateway for all interfaces #include <array.au3> $IntfcKey = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces" Dim $Interfaces[1] ; Array of TCPIP interfaces $Interfaces[0] = 0 For $i = 1 To 10 If RegEnumKey($IntfcKey, $i) = "" Then ExitLoop Else _ArrayAdd($Interfaces, RegEnumKey($IntfcKey, $i)) EndIf Next $Interfaces[0] = UBound($Interfaces) - 1 ; Cell [0] = count of TCPIP interfaces If $Interfaces[0] = 0 Then MsgBox(16, "Gateway Error", "No TCPIP interfaces found!") Exit EndIf Dim $Gateways[$Interfaces[0] + 1][3] ; 2-D array of interface instances and gateways $Gateways[0][0] = $Interfaces[0] ; Cell [0][0] = count of instances For $i = 1 To $Interfaces[0] $Gateways[$i][0] = $Interfaces[$i] If RegRead($IntfcKey & "\" & $Interfaces[$i], "EnableDHCP") = 1 Then $Gateways[$i][1] = 1 $Gateways[$i][2] = RegRead($IntfcKey & "\" & $Interfaces[$i], "DhcpDefaultGateway") Else $Gateways[$i][1] = 0 $Gateways[$i][2] = RegRead($IntfcKey & "\" & $Interfaces[$i], "DefaultGateway") EndIf If $Gateways[$i][2] = "" Then $Gateways[$i][2] = "(Not Set)" Next $Msg = " Interface DHCP? Gateway" & @CRLF & _ "-------------------------------------------------------- ------ -------------" & @CRLF For $i = 1 To $Gateways[0][0] $Msg = $Msg & $Gateways[$i][0] & " " & $Gateways[$i][1] & " " & $Gateways[$i][2] & @CRLF Next MsgBox(32, "Gateway Information", $Msg) This will give you gateways for multiple NICs, and wether or not they are DHCP enabled. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
herewasplato Posted January 25, 2006 Share Posted January 25, 2006 How I can get IP Gateway?...Search the forums using the advanced search, all forums - for "gateway" in the post title.netsh diag show gatewaymight work for you - see this recent thread:http://www.autoitscript.com/forum/index.php?showtopic=18842 [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
JerryD Posted January 25, 2006 Share Posted January 25, 2006 How I can get IP Gateway? Usualy I run commanline like this:If you're using AutoIt beta, you can try First try - _NetGetDefaultGateway - AutoIt ForumsLinks also in my sig below.Jerry Link to comment Share on other sites More sharing options...
Alv. Posted January 25, 2006 Author Share Posted January 25, 2006 How I can run this comman by AutoIT? #Include <process.au3> $value=_RunDOS( "ipconfig | find /i "192.168.100.254"") doesn't work. Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 25, 2006 Share Posted January 25, 2006 How I can run this comman by AutoIT?#Include <process.au3>$value=_RunDOS( "ipconfig | find /i "192.168.100.254"")doesn't work.Thanks for all.I find easy solution:#Include <process.au3>$value=_RunDOS( "ipconfig" & '| find /i "192.168.100.254"')MsgBox(0, "Program returned with exit code:", $value)I'm confused... (not your fault, it's my normal condition) After thinking you wanted to know what the gateway was set to, I just noticed that your code through this whole thread has looked for a specific IP address "192.168.100.254", not the current gateway address. If you already know what the gateway is, why look for it unles you just want to know if it is set as expected? The code I posted earlier in this thread will reliably get gateway address(es) from the registry, so this DOS 'find' and '%ERRORLEVEL%' stuff is not necesary.Am I missing what you are really trying to do? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Alv. Posted January 25, 2006 Author Share Posted January 25, 2006 I'm confused... (not your fault, it's my normal condition) After thinking you wanted to know what the gateway was set to, I just noticed that your code through this whole thread has looked for a specific IP address "192.168.100.254", not the current gateway address. If you already know what the gateway is, why look for it unles you just want to know if it is set as expected? The code I posted earlier in this thread will reliably get gateway address(es) from the registry, so this DOS 'find' and '%ERRORLEVEL%' stuff is not necesary.Am I missing what you are really trying to do? I have 20 laptops and running 2 scriptsfirst script in my office network andsecond script if laptop connected to another networkThank for all answers Link to comment Share on other sites More sharing options...
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