put ip address in an environment variable

M

Marco Berizzi

Is there a way to put the current
ip address (taken from dhcp server)
in to an environment variable?

For example:

C:\>echo %ipaddress%
172.16.1.227
 
P

Pegasus \(MVP\)

Marco Berizzi said:
Is there a way to put the current
ip address (taken from dhcp server)
in to an environment variable?

For example:

C:\>echo %ipaddress%
172.16.1.227

Try this:

@echo off
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "ip address"') do
set IP=%%a
set IP=%IP: =%
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top