title: Batch script: goto was unexpected. using find xyz file.log && goto pass || goto fail
body: <p>I have a very weird error from my batch script.
  Although the code uses Android Debugging Bridge, I'm sure it's an error related to cmd as opposed to adb.
  So, basically if anyone cares, the script just checks root access. Here's a sniplet of the code:</p>
  
  <pre><code>@echo off
  adb kill-server
  adb start-server
  adb shell "su" &gt;check.log 2&gt;&amp;1
  adb kill-server
  "%windir%\system32\find.exe" "#" check.log &amp;&amp; goto pass || goto fail
  :fail
  echo No root access!
  pause
  :pass
  echo Root access detected!
  pause
  </code></pre>
  
  <p>The output for this is:</p>
  
  <pre><code>* daemon not running. starting it now on port XXXX *
  * daemon started successfully *
  * server not running *
  ---------- CHECK.LOG
  goto was unexpected at this time
  </code></pre>
  
  <p>And the window closes automatically.</p>
  
  <p>If I run it in a command window by manually typing the commands, this is what I get:</p>
  
  <pre><code>J:\tools&gt;adb kill-server
  
  J:\tools&gt;adb start-server
  * daemon not running. starting it now on port XXXX *
  * daemon started successfully *
  
  J:\tools&gt;adb shell su &gt;check.log 2&gt;&amp;1
  
  J:\tools&gt;"%windir%\system32\find.exe" "#" check.log &amp;&amp; echo pass || echo fail
  
  ---------- CHECK.LOG
  fail
  </code></pre>
  
  <p>Can anyone think of a solution? I tried to do it like this:</p>
  
  <pre><code>@echo off
  adb kill-server
  adb start-server
  adb shell "su" &gt;check.log 2&gt;&amp;1
  adb kill-server
  SET tr=0
  "%windir%\system32\find.exe" "#" check.log &gt;nul &amp;&amp; SET tr=1 || SET tr=0
  if "%tr%"=="1" goto pass
  if "%tr%"=="0" goto fail
  </code></pre>
  
  <p>I still get the error for goto. :/
  I'm puzzled, I have used other such statements before.
  Thanks for reading through! :)</p>
  
  <p>Oh, system32 is sometimes not present in path &amp; as this is being made for others to use, I need to use %windir%\system32\</p>