As part of a task that I am working on for a customer, I need to make some modifications to the enterprise logon script. Windows command-line is definitely not my area of expertise, but I am doing OK with most it. However, I have one problem that I cannot figure out how to do.
Basically, I need to get the IP address of the machines default gateway into an environment variable (for later use in the script). I know that it exists in the output of both
ipconfig and of
tracert, and I know how to find the exact line in their output that I need, but I cannot figure out how to get beyond that.
For example, the following command produces output like this:
>ipconfig|Find "Default Gateway"|Findstr/N "."|Findstr/B "1:" 1: Default Gateway . . . . . . . . . : 188.8.131.52
But now I need to somehow extract only the IP address out of this text line and then assign it to an environment variable. So, how can I do that from a Windows command-line? (Windows XP and higher).