Run a batch file with Windows task scheduler

Ruben picture Ruben · Dec 14, 2010 · Viewed 516.2k times · Source

I have a batch file daily.bat, this is the code:

cd C:\inetpub\wwwroot\infoweb\factuur\cron
c:\PHP\php.exe -f ./cron_pdf.php
ftp -s:ftp_upload.txt ftp.site.be

And I created a task with task scheduler in Windows 7. When I run the batch manually, everything goes fine, but when I try to run it with the task scheduler nothing happens.

My action is

'run script' "C:\inetpub\wwwroot\site\x\cron\daily.bat"

UAC is off and I am Admin.

Any idea why this is not working?

Answer

Ghazi picture Ghazi · Nov 1, 2012

I faced the same problem, but I found another solution without having to modify my batch script.

The only thing that I missed out is at the 'Action' settings - "Start in (Optional)" option.

Go the task properties --> Action tab --> Edit --> Fill up as below:

  1. Action: Start a program
  2. Program/script: path to your batch script e.g. C:\Users\beruk\bodo.bat
  3. Add arguments (optional): <if necessary - depending on your script>
  4. Start in (optional): Put the full path to your batch script location e.g. C:\Users\beruk\(Do not put quotes around Start In)

Then Click OK

It works for me. Good Luck!