I used SCHTASKS.EXE. There is reference material located here:http://www.ss64.com/nt/schtasks.html and http://support.microsoft.com/kb/814596.
SCHTASKS has several oddities that require work arounds.
First Issue: Deleting old tasks.
Deleting old tasks. SCHTASKS requires that the task name be within quotes while deleting (it does not require the same for creating new tasks). So you have to submit the following
SCHTASKS /Delete /TN "MyDailyBackup" /f
and from AHK it would look like:
DelTask:="SCHTASKS.exe /Delete /TN ""TaskName"" /f" Runwait, %DelTask%,,hide
Second Issue: Add new Tasks
Adding new tasks has some complexities. First you need to provide a windows username/password and domain. The second and more problematic issue is that it does not handle long paths/filesnames easily. Quotes around the long file name do not work. One simple way to circumvent this is to use a LOOP FILENAME, and convert a long filename to a short filename. The other way to circumvent this problem is to place enter the following after TaskRun option:
/TR "\"C:\Documents and Settings\My Documents\folder\script.ahk"
Here is the code:
(This part of the script runs on first run only, and it schedules itself to run at the time you designate every weekday. See the SCHTASKS ref above to change the frequency that the scheduled tasks runs.Change the A_ScriptFullPath to another variable/path if you want to schedule another script/activity. )
Sch_Time := ;Time in 24 hr format ---> hh:mm:ss SCh_UserName := ;Windows Username SCh_Password := ;Windows Password SCh_Domain := ;Windows Domain DelTask:="SCHTASKS.exe /Delete /TN ""ScheduledTask"" /f" Task1:="SCHTASKS.exe /Create /SC weekly /D MON,TUE,WED,THU,FRI /TN ScheduledTask /ST " . Sch_Time . " /TR ""\""" . A_ScriptFullPath . """" . " /RU " . SCh_Domain . "\" . SCh_UserName . " /RP " . SCh_Password Runwait, %DelTask%,,hide Runwait, %Task1%,,hide
The only reference I could find to SCHTASKS not accepting long paths was the following: http://web.archive.o...7000/rh7035.htm
SCHTASKS also keeps a log file. This is useful for debugging. This can be accessed at the Start/Run box by entering: notepad c:\windows\schedlgu.txt
Hopes this helps some of you.
(FYI, I am using a non-admin account on XP. Have not tried this on other versions of windows)