2

I wrote a PowerShell script that check the executable in the < action > tag for each task in the Task directory and mark the < enabled >TRUEorFALSE< / enabled > tag as false/true depending on the validity of the digital signature of the executable. After reading each task, the script re-saves the task file with the same name, type and location.

Now my issue is that I get this message when I lunch task scheduler:

“Task XYZ: The task image is corrupt or has been tampered with.”

This message appears for all the tasks that were scanned and saved.

Does editing task’s xml file directly corrupt the task? Is there any task decency that may cause this error(ex: registry value)?

4 Answers 4

3

This is a security feature. A person or malicious program could edit a task file and insert the location to a hostile program. Windows creates a hash of the task file's various attributes and contents, and stores it in the registry. If the stored hash differs from the calculated hash, Windows prevents the task from running.

If you want to do something like this, delete the task and re-create it with the task set to disabled.

2
  • Do you know can I recover my tasks? I have 10 servers each with 50++ tasks and all of them suffer from the same issue :( I tested my script locally on a test server but I did not notice this error! I have also backed up the Task folder by copy/pasting it into my desktop before I run the script but it seemed that copy/pasting the backup Task folder back to it is original location does not resolve this issue!
    – Eyad
    Oct 20, 2012 at 16:35
  • Sorry, I'm not aware of a method. It may even be the case that after the invalid task is discovered, it would be considered invalid even if restored from a known good copy.
    – Greg Askew
    Oct 20, 2012 at 17:44
2

Export the original task, then modify the exported XML file. Import into another computer or delete the original task before importing the newly modified task.

1

To recover, you can always do an Import to import those XML files as new tasks. (might need to rename the file to .xml)

1

The XML file has a 2 byte prefix consisting of non-ascii characters which cannot be handled by the typical editors (notepad, textpad, ...). When these 2 bytes are destroyed by editing, the file cannot be imported.

1
  • 2
    Just it's the BOM char: it's a file enconded in UTF16
    – 0zkr PM
    Mar 2, 2020 at 19:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .