title: find a word and replace a line with batch file
body: <p>I have a local server on my Windows XP Virtual Box.</p>
  
  <p>Every time my main network changes like from wifi to cable or I move to a different network the IP of my Win XP box changes.</p>
  
  <p>I want to run a batch file to map the new IP to some common name in my hosts file</p>
  
  <p><code>C:\WINDOWS\system32\drivers\etc\hosts</code></p>
  
  <p>for example if I have now:</p>
  
  <p><code>10.97.100.74   www.myAppServer.com</code></p>
  
  <p>and if the ip changes to <code>192.168.11.9</code>,
  I want to search for the string <code>myAppServer</code> in the hosts file and replace the whole line with </p>
  
  <p><code>192.168.11.9   www.myAppServer.com</code></p>
  
  <p>I was able to get the current IP using:</p>
  
  <pre><code>for /f "skip=1 delims={}, " %%A in ('wmic nicconfig get ipaddress') do for /f "tokens=1" %%B in ("%%~A") do set "IP=%%~B"
  
  set IP=%IP%
  </code></pre>
  
  <p>but how do I find that line and replace it?</p>