title: ADB shell "run-as" from a .bat file not finding Unix commands
body: <p>I'm trying to automate the process of pulling the database from my app and then pushing an altered version back to the device, but it's not working as expected.</p>
  
  <p>Following Pilot_51's answer on this topic <a href="https://stackoverflow.com/questions/2078710/android-adb-access-to-application-databases-without-root">Android ADB access to application databases without root</a> I was able to extract the database running the commands manually. But when I put them on a .bat file, every Unix command executed returns a "not found" kind of error. </p>
  
  <p>Here's the error I get:</p>
  
  <p><em>run-as: exec failed for chmod 666 ./database/mydatabase.db; exit Error:No such file or directory</em></p>
  
  <p>And here's the .bat script code:</p>
  
  <pre><code>@echo off
  
  :Ask
  echo (A) Pull or (B) Push
  
  set INPUT=
  set /P INPUT=Input choice: %=%
  
  If /I "%INPUT%"=="a" goto A 
  If /I "%INPUT%"=="b" goto B
  echo Wrong choice &amp; goto Ask
  
  :A
  adb shell "run-as com.example.myapp 'chmod 666 ./databases/mydatabase.db; exit'; exit"
  adb pull /data/data/com.example.myapp/databases/mydatabase.db C:/
  goto End
  
  :B
  adb push C:/mydatabase.db /data/data/com.example.myapp/databases/mydatabase.db
  adb shell "run-as com.example.myapp 'chmod 660 ./databases/mydatabase.db; exit'; exit"
  
  :End
  pause
  </code></pre>
  
  <p>If I try running <em>adb shell</em> with <em>"run-as com.example.myapp 'ls'"</em> only, it does displays the folders. Why is <em>ls</em> working, but <em>chmod</em> doesn't get recognized?</p>