Q. How do I find the IP address of the local computer in a logon script or other batch?

Using only built-in functionality, use the following line to set the ip environment variable:

for /f "skip=1 Tokens=2 Delims=\[\]" %%i in ('ping -n 1 %computername%') do set ip=%%i


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish