title: pgAgent scheduled job failed on Windows
body: <p>I am trying to set up the step with Batch file path on particular time in pgAgent via pgAdmin. But when I run that it is failing and in Step statistics I got this Output</p>
  
  <blockquote>
    <p>C:\Windows\system32>C:\postgresql\run.bat
    'psql' is not recognized as an internal or external command,
    operable program or batch file.</p>
  </blockquote>
  
  <p><strong>Details:</strong></p>
  
  <pre><code>Postgresql 9.3.5 on local system account (Current User)
  pgAdmin 1.18.1
  pgAgent via stack builder with Administrator account (Current User)
  </code></pre>
  
  <p>in <em>run.bat</em> I have only two statement</p>
  
  <pre><code>@echo off
  psql -h localhost -p 5433 -U postgres -d test -a -f "test.sql"
  </code></pre>
  
  <p>I have <strong>psql</strong> in system path variable and able to access it in cmd. When I run that bat file manually it is executing without fail. But when I given the batch file path <code>(C:\postgresql\run.bat)</code> in pgAgent jobs it is giving that error in statistics.</p>
  
  <p>Is there anything wrong in my configuration? Why it is always going to that <code>C:\Windows\system32&gt;</code>?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>My <em>run.bat</em> file</p>
  
  <pre><code> @ECHO OFF
  
  SET LBSDatabaseName=Test
  SET dbHost=localhost 
  SET dbPort=5434 
  SET dbUser=postgres 
  SET logFile=DbInstall.log 
  SET sqlFolder="D:\SOURCECODE\archivescripts"        
  
  "C:\Program Files (x86)\PostgreSQL\9.3\bin\psql.exe" -h "%dbHost%" -p "%dbPort%" -d "%LBSDatabaseName%" -U "%dbUser%" -L "%logFile%" -q -f "%sqlFolder%\Archive.sql"
  </code></pre>
  
  <p>My <em>Archive.sql</em></p>
  
  <pre><code>update "Archive".emp set "FirstName"='Srikanth Dyapa';
  </code></pre>