Task Scheduler Failing to Execute Batch File

Posted on 2009-04-15
Last Modified: 2013-11-29
In a Windows 2003 SBS system using Terminal Server...

In setting up an automated system to present real-time reports to our sales force via their mobile phones, the Scheduled Task that executes a batch file to make the transfer of the reports to our website is failing.

When the batch file is executed manually it works fine but when it is run by a Windows' scheduled task it fails to transfer the files.
No error is reported and the Task Scheduler even shows the time that it last ran and when it is next scheduled again without any indication that anything failed.

The scheduled task that creates the reports is working fine and dumps the reports to the mapped drive T.

I have tried to avoid security issues by setting up all the tasks in the Administrator profile and specifically running each task with Admin. credentials.

The batch file that is executed by the Task Scheduler is ftpMobile.bat and executes the instructions in ftp.txt.bat.

Here is the file contents...

ftpMobile.bat =

ftp.exe -s:C:\FTPMobile\ftp.txt.bat

ftp.txt.bat =

(Username redacted)
(Password redacted)
cd (subfolder name redacted)
put T:\OEDailyOrdersTaken_JH.htm
put T:\OEDailyOrdersTaken_JHPage2.htm
put T:\OEDailyOrdersTaken_ALL.htm
put T:\OEDailyOrdersTaken_ALLPage2.htm
put T:\OEDailyOrdersTaken_ALLPage3.htm
put T:\OEDailyOrdersTaken_ALLPage4.htm
put T:\OEDailyOrdersTaken_ALLPage5.htm
put T:\OEDailyOrdersTaken_ALLPage6.htm
put T:\OEDailyOrdersTaken_ALLPage7.htm
put T:\OEDailyOrdersTaken_ALLPage8.htm
put T:\OEDailyOrdersTaken_ALLPage9.htm
put T:\OEDailyOrdersTaken_ALLPage10.htm
put T:\rptMobileProfitRankJH.htm
put T:\rptMobileProfitRankJHPage2.htm
put T:\rptMobileBulkSchedule.htm
put T:\rptMobileBulkSchedulePage2.htm
put T:\rptMobileBulkSchedulePage3.htm
put T:\rptMobileBulkSchedulePage4.htm
put T:\rptMobileBulkSchedulePage5.htm
put T:\rptMobileBulkSchedulePage6.htm
put T:\rptMobileBulkSchedulePage7.htm
put T:\rptMobileBulkSchedulePage8.htm
put T:\rptMobileBulkSchedulePage9.htm
put T:\rptMobileBulkSchedulePage10.htm

Question by:slamond
    LVL 82

    Accepted Solution

    The scheduled task probably doesn't have the mapped drive available.
    Change your batch file to the following (obviously replacing \\server\share with the actual share T is pointing to):

    >"%LogFile%" echo %Date% %Time%: Skript started
    set LogFile=%~dpn0.log
    net use T: /delete >NUL 2>&1
    net use T: \\server\share >>"%LogFile%"
    ftp.exe -s:C:\FTPMobile\ftp.txt.bat >>"%LogFile%"
    net use T: /delete >>"%LogFile%"

    Open in new window


    Author Closing Comment


    I simply replaced every instance of "T:\" with "\\server\share\".

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    After creating this article (, I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
    After creating this article (, I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now