Hi All,
I've written a DOS batch script that is supposed to run every 10 minutes in the Windows Scheduler (W2K).
But it only runs on about 40% of the scheduled times.
Can you take a look at my script please to see what might be causing the missed runs?
The script, called Run_Downloads.bat, generates another batch file, that in turn, calls a 3rd party http tool (called FT_Connect) to download files from Europe.
The script is included below . .
There are some remarks within the script to describe what the logic is trying to achieve.
TIA.
-------------------------------------------------------------------------------------------------------
@echo off
::
:: Script Name - Run_Downloads.bat
::
:: DOS script to generate the RUN commands for the daily downloads.
:: Run every 10 minutes during the day, via the Windows Scheduler.
::
:: We need a start time and an end time for the download jobs.
:: The end time is "now" and the start time is 11 minutes ago.
::
::
:: Get the current hour and minute.
::
SET CURRENTTIME=%TIME%
for /F "tokens=1 delims=:" %%h in ('echo %CURRENTTIME%') do (set /a HR1=%%h)
SET /A HR2=%HR1%
for /F "tokens=2 delims=:" %%m in ('echo %CURRENTTIME%') do (set /a MIN1=%%m)
SET /A MIN2=%MIN1%
::
:: If the minute is <= 09, roll it back by adding 60 to minutes and
:: subtracting 1 from hours.
:: Then subtract 10 minutes for the start time and subtract 1
:: more minute for the time overlap.
::
:: === CONFIGURE THE -FROM- TIME =====================================================
IF %MIN1% LEQ 10 (
SET /a MIN1=%MIN1%+49
SET /a HR1=%HR1%-1
) ELSE (
SET /a MIN1=%MIN1%-11
)
:: Subtract 7 hours from the time, due to the time zone difference between Singapore and France.
SET /a HR1=%HR1%-7
::
:: Pad single digit minutes with a leading zero
::
IF %MIN1% LEQ 9 (
SET MIN1=0%MIN1%
)
::
:: Pad single digit hours with a leading zero.
::
IF %HR1% LEQ 9 (
SET HR1=0%HR1%
)
::
:: Use the new hour and minute (and existing seconds) to create the -FROM- time.
::
SET FROMTIME=%HR1%:%MIN1%:%CURRENTTIME:~6,2%
ECHO From Time is %FROMTIME%
:: === CONFIGURE THE -TO- TIME ========================================================
:: Subtract 7 hours from the HOUR component due to the time zone difference between SGP and Germany.
SET /a HR2=%HR2%-7
:: IF %HR2% LEQ 9 (
:: SET /a HR2=0%HR2~2,1%
:: )
::
:: Pad single digit minutes with a leading zero
::
IF %MIN2% LEQ 9 (
SET MIN2=0%MIN2%
)
::
:: Pad single digit hours with a leading zero
::
IF %HR2% LEQ 9 (
SET HR2=0%HR2%
)
::
:: Use the new hour and minute (and existing seconds) to create the -TO- time.
::
SET TOTIME=%HR2%:%MIN2%:%CURRENTTIME:~6,2%
ECHO To Time is %TOTIME%
SET DATE1=%date:~10,4%-%date:~4,2%-%date:~7,2%
@echo FT_CONNECT 4 -ttf %DATE1%T%FROMTIME% -ttt %DATE1%T%TOTIME% -d -n D:\Import\Temp >D:\FileTransfer\versions\V2.08
\File_Import.bat
:END
call D:\FileTransfer\versions\V2.08\File_Import.bat
-------------------------------------------------------------------------------------------------------