title: Azure DevOps Server: How to prevent 'Access to path is denied' when initalizing a job?
body: <p>I am using <a href="https://docs.microsoft.com/en-us/azure/devops/user-guide/about-azure-devops-services-tfs?view=azure-devops" rel="nofollow noreferrer">Azure DevOps Server 2019</a> (ADOS for short, installed on-premises) to run end to end tests based on Selenium in C#.</p>
  
  <p>Every now and then a build ends badly without properly stopping the <a href="https://chromedriver.chromium.org/" rel="nofollow noreferrer"><code>chromedriver.exe</code></a> process used by my Selenium tests. As a result, the subsequent build fails at the <em>Initialize Job</em> step with an error that looks like this:</p>
  
  <blockquote>
    <p>One or more errors occurred. (Access to path 'C:...\chromedriver.exe' is denied.)</p>
  </blockquote>
  
  <p>What I understand from this is that because <code>chromedriver.exe</code> is still running ADOS cannot delete its <code>.exe</code> file when it tries to clean the working folder at the start of the build run.</p>
  
  <p>I've tried disabling the <em>Clean</em> feature of the <em>Get sources</em> step definition but that only shifted the error a bit forward to the <em>Checkout</em> step.</p>
  
  <p>To resolve the problem I am forced to manually RDP into my agent machine, <code>taskkill /IM chromedriver.exe /F</code> and re-run the failed build.</p>
  
  <p><strong>My question is</strong> - How can I prevent the access denied error? I've thought of these approaches but I'm not sure which is practical:</p>
  
  <ol>
  <li><p>Get ADOS to run <code>taskkill</code> automatically before the <em>Get sources</em> step. How?</p></li>
  <li><p>Make the agent have higher privileges so it can delete <code>chromedriver.exe</code> even when its process is still running. Again, how?</p></li>
  </ol>