title: how to add new lines to windows hosts with a batch file
body: <p>i know this was already discussed but i didn't find what i needed.
  I need to add new lines at the end of the hosts window file but,
  first i need to check if these lines already exist and than adding them.</p>
  
  <p>I tried this:</p>
  
  <pre><code>set "list=examp.com=examp2.com=examp3.com"
  SET NEWLINE=^0.0.0.0
  for %%a in (%list%) do  (
     FINDSTR /I %%a %WINDIR%\system32\drivers\etc\hosts)
     IF %ERRORLEVEL% NEQ 0 (ECHO %NEWLINE% %%a&gt;&gt;%WINDIR%\System32\drivers\etc\hosts)
     pause
  </code></pre>
  
  <p>but the result in hosts is just 1 line like this:</p>
  
  <pre><code>0.0.0.0 %a
  </code></pre>
  
  <p>I also want to know if it's possible to change this:</p>
  
  <pre><code>set "list=examp.com=examp2.com=examp3.com"
  </code></pre>
  
  <p>with another code that will take variables from a txt file.</p>