Task Scheduler runs but fails to associate .hta file when mshta.exe selected

Tim A123 20 Reputation points
2023-09-19T18:34:36.09+00:00

Hi,

I have set up task scheduler to execute a .hta file.

When Task scheduler runs and tries to open the .hta windows asks how I want to open the file:

User's image

I select "Look for another app on this PC" I navigate to C:\Windows\SysWOW64\mshta.exe

Error message pops up:

User's image

There are no issues when running the .hta manually but when I run it through task scheduler I'm prompted to select program. I also checked that the .hta is set to open with HTML application:

User's image

Did select the wrong program? Is there a program in Program Files that I should be running instead?

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 36,401 Reputation points
    2023-09-19T19:42:27.4933333+00:00

    Configure your task to execute program C:\Windows\System32\mshta.exe. In the arguments field enter the full path to the hta file. If you've got some kind of 32 bit requirement, then use the SysWOW64 version.

    You should only do that if you've set the task to "run only when the user is logged on". That way the GUI window will be visible to you on the desktop.

    If you need it to run unattended, "Run whether user is logged on or not", then you should convert the code to VB script or Powershell so that you can use a command line program (like cscript.exe) to run it.

    The issue is that GUI programs tend to display message boxes and in unattended mode, you have no visibility to the window and thus no way to "click ok to continue".

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.