BinaryBrother Posted September 5, 2011 Posted September 5, 2011 (edited) Func _GetGatewayIP() Local $StreamHandle, $StreamOutput, $DG If @OSVersion = "WIN_7" Then $StreamHandle = Run(@ComSpec & ' /c ipconfig /ALL | find "Gateway"', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) If @error Then SetError(1) Return EndIf While 1 $StreamOutput &= StdoutRead($StreamHandle) If @Error then ExitLoop WEnd $DG = StringRegExp($StreamOutput, "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",3) If IsArray($DG) Then Return $DG[0] Else SetError(2) Return endif EndIf EndFunc The ipconfig output changed from XP to Win7, so I'm not sure if this will work for XP. Works fine for single gateway configurations on 7 though. Other examples were either designed for XP or utilized a temp file, this is an improvement over most other versions I've seen floating around the forums. Edited September 5, 2011 by BinaryBrother SIGNATURE_0X800007D NOT FOUND
JScript Posted September 9, 2011 Posted September 9, 2011 Nice! And it has possibilities of using WMI? João Carlos. http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Reveal hidden contents Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
BinaryBrother Posted September 9, 2011 Author Posted September 9, 2011 WMI? This uses an IO stream from the CLI took "ipconfig". Much faster than WMI, IMO. SIGNATURE_0X800007D NOT FOUND
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