For the Wiki (Windows Task Scheduler)
Posted: Tue 16 Jan 2024 10:47 am
Hi Hans,
Wrote a part for the wiki article for the Cutils page
https://www.cumuluswiki.org/a/CumulusUtils
Specifically the Scheduled task
Hope that it is sufficient for your needs?
Not sure of the best default switch or rather command to use in the bathc file, as I don't use it in it's native manner, guessed website?
How to create a scheduled task
Prior to doing this we need to also create the script that the task will use.
(Lines that begin with REM are provided for explanation purposes and can be removed)
Task creation process
Within the Task Scheduler Library
One can also customise/fine tune the task further by exporting it, default export format is XML. Then can edit in favourite text editor and reimport when done. May be useful in particular for fine tuning the repetition times of the task.
Wrote a part for the wiki article for the Cutils page
https://www.cumuluswiki.org/a/CumulusUtils
Specifically the Scheduled task
Hope that it is sufficient for your needs?
Not sure of the best default switch or rather command to use in the bathc file, as I don't use it in it's native manner, guessed website?
How to create a scheduled task
Prior to doing this we need to also create the script that the task will use.
- Open notepad or your favourite text editor (encourage the use Notepad++)
- Can copy paste the below and save as cumulusutils.bat
(Can be a filename of choice but must have extension of .bat, if using windows notepad, underneath the File name: option, will need to set Save as type: option to All Files (*.*). This way when the File name: is set as cumulusutils.bat it will save it as that and not cumulusutils.bat.txt)
(Lines that begin with REM are provided for explanation purposes and can be removed)
Code: Select all
REM This batch file script checks for the process CumulusMX.exe is running, if yes, then runs the "cumulusutils.exe", otherwise exit
REM Set the current working session to the folder C:\CumulusMX
cd\
cd C:\CumulusMX
REM Check for CumulusMX.exe is running, if yes goto :runutils, otherwise goto :end
tasklist /FI "IMAGENAME eq CumulusMX.exe" 2>NUL | find /I /N "CumulusMX.exe">NUL
if "%ERRORLEVEL%"=="0" GOTO runutils
GOTO end
REM Set as working directory C:\CumulusMX and run cumulusutils.exe in folder C:\CumulusMX\utils\bin, with the desired command or commands as per the wiki
:runutils
START /D C:\CumulusMX C:\CumulusMX\utils\bin\cumulusutils.exe Website
:end
exit
Within the Task Scheduler Library
- Create “New Task…” (actions pane), or right click middle pane and choose “Create New Task” (not Create Basic Task).
- On the General tab of the new task (General information about the task).
- Set desired name for the Task (Example name CumulusUtils, can also set description if desired).
- Click “Change User or Group…”.
- Type in here the word system (click on “Check Names” if desired, to confirm it is correct and it should then display as SYSTEM in capitals).
- Click OK to use this user account.
- Note in Security options part of the new task creation process it should now state under.
When running the task, use the following user account:
NT AUTHORITY\SYSTEM
(Convenient reason for this is that when the task runs, it runs is running as system account and so is not seen popping up on screen when it is running.) - “Configure for:” not required to be changed, can be changed to version of operating system.
- On the Triggers tab of the new task (Setting when and how often the task runs).
- Click on “New”, to create a new launch time and frequency of the task.
- Begin the task: option should default to “On a schedule”, this is the desired option.
- Under the settings section choose “Daily” option.
- Start: date can be left as is, set the desired start time of the task. Set to “12:00:15 am”.
(Reason for this setting with 15 second delay is trying not to compete with CumulusMX upload tasks). - In the advanced part, enable Repeat task every: and choose desired interval.
With the option for a duration of: default setting of “1 day” is used. - Set Stop task if it runs longer than: to “30 minutes” (if the task runs longer than the time set, it is stopped. This applies to the individually triggered task, and not the overall routine of this scheduled task, with it’s repeating trigger times).
- Confirm that the Enabled options is ticked to make active this trigger routine.
- On the Actions tab (Setting what the task is to do).
- Click on “New…” to create a new action.
- Action: should default to “Start a program” this is correct.
- In the Program/Script: part, type the path to the program to run, or click “Browse” to navigate and select the program to run. (example C:\CumulusMX\batch_files\cumulusutils.bat).
- On the Conditions tab (setting other conditions).
- Under Power, untick Start the task only if the computer us on AC power
(This then enables the task to start and run even if on battery. It will automatically untick Stop if the computers switches to batter power.)
- Under Power, untick Start the task only if the computer us on AC power
- On the Settings tab (additional other settings for the task).
- Confirm ticked for Allow task to be run on demand.
- By default Stop the task if it runs longer than: is already ticket and set as 3 days.Change to 1 hour (the behaviour here is the same as instruction 3.f.)
- Confirm ticked for If the running ask does not end when requested, for it to stop.
- Default setting of “Do not start a new instance” Is OK.
- Click on OK down the bottom to complete and commit the creation of this new task.
One can also customise/fine tune the task further by exporting it, default export format is XML. Then can edit in favourite text editor and reimport when done. May be useful in particular for fine tuning the repetition times of the task.