title: Command To Close an Open File
body: <p>I am trying to create a .CMD file to easily copy and paste a revised file (i.e. test.pdf) overwriting the old file with the new one. The problem is that if the old file is currently open by a user on the network then I cannot paste over it or delete it. I tried using the <code>DEL /F "test.pdf"</code> command but it still doesn't force the delete. I know that there is the command <code>net file &lt;ID&gt; /close</code>, but <code>&lt;ID&gt;</code> is dynamic and will never be the same twice. Is there any way to determine the <code>&lt;ID&gt;</code> of the file in the script knowing the path and file name? Or is there another way to close an open file within a CMD file? Another problem is that multiple users can have the file open simultaneously...</p>
  
  <p>Note: I know that closing an open file is not good practice as it can cause data loss, however this is simply a PDF file that I am replacing. Even if the old file gets corrupted, it is going to be erased anyway. </p>