batch script in task scheduler failing to copy file to ftp server

Naveen Mareddy 1 Reputation point
2021-03-03T11:39:47.783+00:00

I have task scheduler to take dbback and copy it to ftp server. But task scheduler failing with error system error code:2. However, i am able to run script manually and it successfully copied backup file to ftp server. Please help me

Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,368 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,083 questions
{count} votes

3 answers

Sort by: Most helpful
  1. MotoX80 31,566 Reputation points
    2021-03-03T13:09:32.29+00:00

    You need to troubleshoot the commands that the .bat file is executing. In the task definition set the "Program/script" to execute cmd,exe. In the "Add arguments (optional)" field set it to "/c C:\YourFolder\YourBatFile.bat 1>C:\YourLogFolder\YourBatFile.log 2>&1".

    That will capture both stdout and stderr into a log file that you can review. Use your folder and file names.


  2. Karlie Weng 13,951 Reputation points Microsoft Vendor
    2021-03-04T07:09:50.96+00:00

    Hello @Naveen Mareddy

    Did you enter the full path of the program in “Start In (Optional)” field?

    Though the option says “optional”, the script or the executable you want to run cannot depend on the current directory being set to what you might expect. Another thing about the “Start In (Optional)” field, don’t add quotes in this field.

    Even if the name of the folder or the directory contains spaces, quotes are not required nor allowed. You can do a little experiment to see if quotes can be used or not in this field. If not then just remove it.

    74138-image.png

    Or you could Deleted & re-created the scheduled task and Run with the highest privileges

    Best Regards
    Karlie

    ----------

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. Andrea Zoffoli 1 Reputation point
    2022-05-19T09:18:06.607+00:00

    I also had the same problem, I solved it like this:

    in the batch file you must first insert this line:

    PUSHD: C \ folder containing batch file

    this worked for me

    0 comments No comments