Jump to content
Sign in to follow this  
vickerps

IP address

Recommended Posts

vickerps

Hi Guys

I know about @IPadress1

But i also want Subnet and Gateway how can i get these

Share this post


Link to post
Share on other sites
ezzetabi

Parsing IPConfig /all result?

Share this post


Link to post
Share on other sites
Davman

This should do ya:

ipconfig /all > c:\temp1.txt

Will dump the result in C:\temp1.txt

$filename = "C:\temp1.txt"
$file = FileOpen($filename, 0)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
While 1
$line = FileReadLine($file)
If @error = -1 Then
;Do what you like...
EndIf
if StringInStr($line, "Subnet") <> 0 Then
;You've found the line with "Subnet" in it, so parse this as you like
EndIf
if StringInStr($line, "Gateway") <> 0 Then
;You've found the line with "Gateway" in it, so parse this as you like
EndIf
Wend

Something like that anyway, this is untested, so dont quote me on it.


Sitting comfortably behind the code.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.