JSI Tip 7390. How do I set an environment variable to the IP address of the client computer in a logon script?

If your logon script requires that you retrieve the IP address of the client computer, add the following to the script:

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

Hide 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.