• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 505
  • Last Modified:

Task Scheduler Failing to Execute Batch File

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 =

open (IP ADDRESS REDACTED)
(Username redacted)
(Password redacted)
cd (subfolder name redacted)
bin
hash
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
bye


0
slamond
Asked:
slamond
1 Solution
 
oBdACommented:
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

0
 
slamondAuthor Commented:
Excellent!!!

I simply replaced every instance of "T:\" with "\\server\share\".
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now