title: Inno Setup throws exception "The process cannot access the file because it is being used by another process." on repeated use of ExtractTemporaryFile
body: <p>I have an Inno Setup script with silent install options that have procedure that uses <code>ExtractTemporaryFile</code>:</p>
  <pre class="lang-pascal prettyprint-override"><code>procedure SetAccessPermission(folderName : string; groupName : string );
  Var
    output : string;
    ErrorCode : integer;
  begin
    ExtractTemporaryFile('EnvironmentAdjustment.exe');
    ExtractTemporaryFile('EnvironmentAdjustment.exe.config');
    ExtractTemporaryFile('Win32Security.dll');
    ShellExec('', ExpandConstant('{tmp}\EnvironmentAdjustment.exe'),
      ExpandConstant('&quot;' + folderName + '&quot; &quot;' + groupName + '&quot; '),
      ExpandConstant('{tmp}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
    LoadStringFromFile(ExpandConstant(resultPath + '\folderaccess.txt'), output);
    Log('Result: ' + SysErrorMessage(ErrorCode) + ')');
  end;
  </code></pre>
  <p>That procedure is used several times in the code:</p>
  <pre class="lang-pascal prettyprint-override"><code>SetAccessPermission('{app}\WebSite\imagescache', groupForSettingReadWritePermisions);
  SetAccessPermission('{app}\WebSite\formscache', groupForSettingReadWritePermisions);
  </code></pre>
  <p>But on the second use exception is thrown:</p>
  <blockquote>
  <p>The process cannot access the file because it is being used by another process.</p>
  </blockquote>
  <p>I've added some logs and found that it definitely fails on the first <code>ExtractTemporaryFile</code> executing. No any existing processes don't use that file, so I think that's something inside in Inno Setup. I wasted too much time to understand what goes wrong, but I have not idea still. Also, this issue occurs only on single machine with Windows Server 2012 R2 (and even there such problem started only some time ago), script is executed properly on all others, so that adds more questions.</p>