It’s really not possible to create (and recreate) tasks per command line in Windows XP.
The solution I came up with was to create in a single task several triggers which is very annoying, so I would prefer a BAT to do it.
I activated the checkbox
option Show multiple schedules:
So I could have access to the 'New' button where includes a trigger with repeater identical to the previous one, but with an hour more:
When I created one for each time (standard 24 hours), from 00:00 until 23:00
So when the system starts (remembering that all triggers start without user authentication, that is only after LOGON).
To complete I copied the file *.JOB
from the TASKS folder to my application folder.
copy %windir%\tasks\mystask.job %homedrive%\myapp\
As even to stop ('/end') or delete ('/delete') keep giving errors I created in the menu of my application a method to "TURN ON" and "OFF" the schedule.
@ECHO OFF
:STARTAPP
IF EXIST %windir%\tasks\mystask.job (
SET ABKP=ON
) ELSE (
SET ABKP=OFF
)
CLS
ECHO [1] Menu 1
ECHO [2] Menu 2
ECHO [3] Ativar ou desativar AUTOBACKUP: %ABKP%
ECHO [4] Menu 4
ECHO.
SET /P SLT= Selecione um dos itens acima:
IF "%SLT%"=="1" (GOTO OPTION1)
IF "%SLT%"=="2" (GOTO OPTION2)
IF "%SLT%"=="3" (GOTO OPTION3)
IF "%SLT%"=="4" (GOTO OPTION2)
:OPTION3
IF EXIST %windir%\tasks\mystask.job (
COPY %HOMEDRIVE%\myapp\mytask.job %windir%\tasks\
) ELSE (
DEL %windir%\tasks\mystask.job
)
GOTO STARTAPP
And the best, how it works only after the user "logged in" then independent of the machine I put or user that is running when the file *.JOB
is copied to folder TASKS and you check the properties it automatically changes the user to whatever is running, ensuring that it will work since it does not request authentication.