Task Scheduler having issues running .hta in Windows 10 environment

Tim A123 20 Reputation points
2023-05-25T21:16:36.53+00:00

Hi,

We have workstations that need to be restarted at least once a week. We created an .hta file to run. The .hta file consists of a countdown and message that notifies end user that a reboot will take effect after 60 seconds. If they are still working on that workstation they can cancel the .hta and will cancel tasked schedule to be repeated the following week. Since we upgraded our workstations from Windows 8 to Windows 10 Pro 20H2 the tasks scheduler will fail to run. When we try to run the .hta independently it will open but not execute the reboot at the end of the timeout. I was reading online that there is an issue with HTA files and windows 10. If that is the case is there any remediation that can be done. Also, are there alternative types of script that can be ran on task scheduler that can server the same purpose (vscript,bat,etc) Maybe even group policy alternative.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,616 questions
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,746 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
868 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 31,571 Reputation points
    2023-05-26T22:33:33.1433333+00:00

    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.