title: How to Lock a file exclusively for 1 minute using windows batch script?
body: <p>I have a need to lock a file exclusively and continuously keep writing content to it on windows 7. 
  Objective: While the file is being written with an exclusive lock there is a SFTP schedule that pulls this file from a different server. We need to verify if the file is being pulled partially even if there is a Exclusive Lock on the file.
  Used the below batch script but how do i get a lock for 30 seconds to 1 minute?</p>
  
  <pre><code>@echo off
  if '%1' == '-lock' (
      shift
      goto :main
  )
  call %0 -lock &gt; SAMPLEFILE.csv
  goto :eof
  :main
  ping -n 30 127.0.0.1 &gt; nul
  echo %DATE% %TIME% - start
  TREE C:\
  echo %DATE% %TIME% - finish
  goto :eof
  </code></pre>