I would recommend PowerShell. There are examples out on the internet. Here is one.
https://www.red-gate.com/simple-talk/sysadmin/powershell/building-a-countdown-timer-with-powershell/
Having said that, on my Win11 laptop I have a copy of the old ScriptoMatic.hta file. I defined a task to execute program mshta.exe with an argument of C:\Utils\ScriptomaticV2.2.hta. I had to check off the "Run with highest privileges" since the WMI calls required admin access. I set the task to run as the Users group and "Run only when the user is logged on". The hta seems to work just fine. I am a member of the administrators group.
In order to help you with your .hta file, I would need to know what error you are getting. Did you configure the task to run mshta.exe? Is the user a member of the administrators group? What entries are in the History tab for the task? Do you get an error code?
Do you have error handling and logging in your hta code? I'm a VB guy so I would do a ON ERROR RESUME NEXT and then check err.number. If it is not equal zero write out the err.description to a log file and note what the code was trying to do.