title: CMD if ping successful do this
body: <p>i have situation that i can not understand, i am trying to do a batch file where he loops 200 times and in each loop he pings a host, if the ping is successful he does a command. Here is what i got:</p>
  
  <pre><code>    @echo off
  for /L %%N IN (1, 1, 200) DO (
      ping -n 1 192.1.22.%%N
      if not ERRORLEVEL 1 (
          set pingresult=true
          goto done
      )
  )
  
  set pingresult=false
  :done
  if %pingresult% == true (
   echo Pikachu
  
  
  ) else (
    echo "Offline!"
  )
  </code></pre>
  
  <p>it doesn't work.</p>