How do I parse the octets of an IP address into environment variables on a batch file?
Posted on 2008-06-18
Does anyone know of a way to parse the octets of an IP address into environment variables in DOS? There has to be some trick using loops or something to do this. I would think... :)
What I would like to do is parse the first three octets into one environment variable and just ignore the final octet.
So if I had an IP address if 192.168.100.1, I would like to create an environment variable named %MYIP% and have it contain "192.168.100".
Is this doable? Thanks in advance...
P.S. If it would be easier to parse each octet into its own variable such as %OCTET1%, %OCTET2%, etc... I could use that too. But I'd prefer to have the first three octets in one variable if possible.