title: Check which files are currently being used using a windows batch script
body: <p>I'm trying to make a batch script to check each file in a directory and wait if one of them is currently being used by a process in windows. This solution is based on <a href="https://stackoverflow.com/a/2542831/133001">this answer from stackoverflow</a>. The objective is to execute the following script in Jenkins before deploying an application using MSDeploy to make sure no dll is being used in the application folder:</p>
  
  <pre><code>FOR /F "delims=" %%A in ('dir C:\Folder\%1\*.dll /b') do (
  :TestFile
  ren C:\Folder\%1\%%A C:\Folder\%1\%%A
  IF errorlevel 0 GOTO Continue
  ping 127.0.0.1 -n 5 &gt; nul
  GOTO TestFile
  :Continue
  )
  </code></pre>
  
  <p>However when running this script, either as a stand-alone or through a Jenkins Windows Command step, it shows the following error when executing the FOR loop:</p>
  
  <pre><code>Warning: ) was unexpected at this time. 
  </code></pre>
  
  <p>What could be the reason behind this error?</p>
  
  <p>Thanks!</p>