title: How to avoid I/O error 32 when handling file being used by software
body: <p>I have a scientific instrument with some software that leaves something to be desired... but it's proprietary and I can't do anything about changing how the software works. So I'm trying to play nice with it. </p>
  
  <p><strong>Here's my setup:</strong></p>
  
  <p>The software creates a text file to store the data. With every new observation (every 10 seconds) it appends the latest observation to the text file. I want to save the file to a shared network drive so I can have instant up-to-date access of the file on my other computer. However, if the laptop loses connection to the network drive for even a small amount of time while the software tries to write to the file, the software breaks and all observations after that are lost into cyberspace. I get I/O Error 103.</p>
  
  <p>So here's a little batch file I've written up to save the data locally on the hard drive first and then make copies periodically:</p>
  
  <pre><code>set /p name= File name (without ".txt"):
  set source= C:\Users\Admin\Desktop\%name%.txt
  set destination= Z:\SKQ201701S\Birk_data\O2\%name%.txt
  
  :loop
  copy %source% %destination%
  timeout /t 10
  goto loop
  </code></pre>
  
  <p><strong>Here's my problem:</strong></p>
  
  <p>Sometimes I get I/O error 32. From what I've read, this is due to multiple programs trying to access the same file at the same time. So I'm assuming that sometimes the software tries to append a new observation to the file while my batch script is copying the file. When that happens, I get the error message. I've read about files being locked when they're accessed, but maybe this software doesn't lock the file while writing? I'm not sure...</p>
  
  <p>How can I avoid this happening? All the answers I've found so far assume that both of the processes are under the user's control. Typically in the same batch script. But in my case I can't control the proprietary software.</p>
  
  <p>I'm on Windows 7. Any ideas?</p>