Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:18 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Windows Scheduled Task /Script.

Author Message
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:31pm 22 Jun 2019
Copy link to clipboard 
Print this post

Hi All,

A Windows one that's always eluded me of going on 3 years.

Running a Weather station here that uploads to the Web,

Phil's Weather Station & it's Console.

It uses software called CumulusMX which is a command line app that builds htm files that make up the software's user interface.
It runs 24/7 & ftp's to my site & a few others.
Connects via USB with a CP2102 interface.

On an old Win8.1 laptop, so the Startup Group doesn't work to launch it at logon, so I launch it with Task Scheduler.

All that works fine.
But the station comes with another piece of software called weatherLink, that I want to update periodically.

I can do that manually by closing Cumulus; executing a command that forces WeatherLink to launch, connect, & then download new data then exit.

The manual process is what I want to automate & have tried on & off for years with little success.

Below is what I've posted on several weather forums, but have yet to get any responses.

Anyone got any suggestions?

================================================================================

Ok,

So I have a Scheduled Task that starts Cumulus on boot & it runs happily.

Periodically I shut it down & update Weatherlink Via a shortcut that point to:-
"C:\WeatherLink\WeatherLink 6.0.3.exe" -d

Then Start Cumulus again with the Desktop link that points to:-
C:\Windows\System32\schtasks.exe /run /tn "\Weather Tasks\Start Cumulus"
The Task that starts it on login.

Would like to automate it so it happens at least every day, but always seem to get in a know athe the launch task is constantly sitting in the running state, (0x41301) untile Cumulus is terminated.

Have had multiple tries over the years without complete success.

For example this task,

[code]
C:\CumulusMX\CumulusShutdown.exe (That exe is an AutoHotKey complied script that focuses on the MX window & sends it Ctrl-C)
ping -n 5 localhost
"C:\WeatherLink\WeatherLink 6.0.3.exe" -d
ping -n 5 localhost
C:\CumulusMX\CumulusMX.exe
[/code]

The AutoHotKey Script:-

[code]
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
WinActivate, C:\CumulusMX\CumulusMX.exe
Send ^c
Return
[/code]


Everything seems to get caught in the loop if tasks being still running while Cumulus is running.

It shouldn't be that hard as I have a means to shutdown Cumulus, & a command line to download the WL data then exit.
The pings above are a simple delay so the task don't execute too quickly.

Any thoughts or suggestions?

Cheers.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:43pm 22 Jun 2019
Copy link to clipboard 
Print this post

I would start by increasing your delays.
Cumulus can take a long time to shut down.

VK7JH
MMedit
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 11:22pm 22 Jun 2019
Copy link to clipboard 
Print this post

Hi Jim,

Tried all that; tried having Task Scheduler launching a batch file instead or running commands...

All attempts appear to have a looping issue on subsequent launches.

That's where I reckon it's somehow related to the (0x41301) status that the Scheduled tasks sit in.

That's the "Still Running" state.

I reckon I need to have it get to the (0x0) state, completed, before doing other stuff.

Re Cumulus taking a long time to exit; I've notice a huge improvement in that issue in the latest releases.

Not sure if you are aware, but since Steve (Author) retired a back in 2017, circa V3046, the software is now being supported & developed again.

Steve released the source code in Dec 2018 & it's now being updated again.

Mark Crossley is heading that up now.
He's the guy that's been responsible for the code for gauges & graphs etc.

His latest release is v3050 & was posted 1'st May 2019.

Cheers

Phil.
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 11:32pm 22 Jun 2019
Copy link to clipboard 
Print this post

This.....





The task still running....

I think I need it to reach the "Completed" state once CumulusMX.exe is launched & running.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 12:11am 23 Jun 2019
Copy link to clipboard 
Print this post

Never liked the scheduler, I prefer to write my own or use a windows version of CRONTAB

I would definitely use a batch file and get that working and exiting first.
You probably need to start Cumulus with "start" in the batch file so it will complete.

I use Cumulus on a RPi. Not the latest version but not too far behind.

Jim
VK7JH
MMedit
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 12:42pm 23 Jun 2019
Copy link to clipboard 
Print this post

  TassyJim said   Never liked the scheduler, I prefer to write my own or use a windows version of CRONTAB

Hmmm ... a little searching shows there is such a thing as the "AT" command. Interesting. "AT /?" yields
[code]The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.[/code]Edited by lizby 2019-06-24
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 01:51pm 23 Jun 2019
Copy link to clipboard 
Print this post

AT is the CLI access to the task scheduler
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:50pm 23 Jun 2019
Copy link to clipboard 
Print this post

I had a rummage around and found my old windows CRON.EXE
I don't have any clue about the author but I used it for many years and it still works under Windows 10!
VirusTotal gives it a clean bill of health.
2019-06-24_084753_cron.zip
If you put your batch files in the same folder as the exe, you don't need the path, something that makes it reasonably portable.

Phil,
You still need to get a working batch file before you worry about scheduling it or you could try the three commands you already have one minute apart.

JimEdited by TassyJim 2019-06-25
VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 07:13am 24 Jun 2019
Copy link to clipboard 
Print this post

This ZIP contains cron, sendkeys, and a couple of batch files.
You will need to change the path to your EXEs

sendkeys is my version of AutoHotKey

To start CumulusMX from a batch file, you need to CD to the program folder first.
If you use START in a batch file so the batch completes, you need to specify the window title or sendkeys can't find the window to send ctrl-C to it. See startMX.bat

You should be able to combine the actions into one batch file but start with individual files.
2019-06-24_171248_cron.zip
Jim

VK7JH
MMedit
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025