title: Cannot run a batch file from SQL Server Agent (Access denied)
body: <p>I am trying to execute a batch file from SQL Server Agent (as it needs to be done before some SSIS-packages are run).
  When I execute the job it fails in a few seconds saying "Access denied".</p>
  
  <p>The account under which SQL Server Agent runs has full control on the folder that contains the batch file. The result of the batch would be deleting some files in a folder, calling a webservice and get those same files back from the webservice.
  I can run the batch file when I start it with my own (admin) account. </p>
  
  <p>I googled and found several other questions and answers but none of those were covering my problem. I hope you can point to other options.</p>
  
  <p>Thanks for your help.</p>
  
  <p>Johan</p>
  
  <p>Batch file contents: </p>
  
  <pre><code>echo Removing txt files of last run
  del Employees.txt
  del HrDepFun.txt
  del HrEmpActual.txt
  echo Files removed
  echo Starting getconnectors
  {Call Webservice} -&gt; cannot disclose this on stackoverflow
  echo Getconnectors done
  </code></pre>
  
  <p>Batch file execution statement from SQL Server Agent job (type Operating System (CmdExec)):</p>
  
  <pre><code>cmd.exe /c "c:\Program Files (x86)\AFAS\AFASRemote_Call_GetConnectors.bat" &gt; connectorlog.txt 2&gt; connectorerrorlog.txt
  </code></pre>