Windows 10 schtasks The task XML is malformed.

Cardinal System

Honorable Member
Joined
Jan 24, 2016
Messages
87
Hello,

I am trying to import a scheduled task from from the command line to the task scheduler. Before my program runs the schtasks command, it inserts a file path in the
Code:
<Command></Command>
element. The XML file works with schtasks before I insert my file path, but not afterwords. It keeps giving the same message:

Code:
ERROR: The task XML is malformed.

(1,2)::ERROR: incorrect document syntax

Interestingly enough, I am able to import the task with the Task Scheduler GUI. Not sure why schtasks is not working here. I am using the same UTF-16 and everything. I will link the XML file to this thread in case you want to take a look at it: Link Removed

Any help is appreciated!
 


Last edited:
Solution
It seems like you are facing an issue while trying to import a scheduled task using schtasks from the command line due to a malformed XML structure in the task file. The error message indicates there's a syntax issue that is preventing the task from being imported successfully. Here are a few steps you can take to troubleshoot this issue: 1. Check XML Formatting: Ensure the XML file you are trying to import is correctly formatted. Even a small syntax error or misplaced element in the XML structure can cause the import to fail. You can use an XML validator or editor to verify the structure. 2. Character Encoding: Confirm that the XML file is saved with the correct character encoding, UTF-16 in this case. An incorrect...
It seems like you are facing an issue while trying to import a scheduled task using schtasks from the command line due to a malformed XML structure in the task file. The error message indicates there's a syntax issue that is preventing the task from being imported successfully. Here are a few steps you can take to troubleshoot this issue: 1. Check XML Formatting: Ensure the XML file you are trying to import is correctly formatted. Even a small syntax error or misplaced element in the XML structure can cause the import to fail. You can use an XML validator or editor to verify the structure. 2. Character Encoding: Confirm that the XML file is saved with the correct character encoding, UTF-16 in this case. An incorrect character encoding can lead to parsing issues. 3. Command Line Parameters: Double-check the command you are using to import the task. Ensure that all parameters passed to schtasks are correct, including the /Create parameter and appropriate rights for creating tasks. 4. Test with Basic Task: Try creating a simple task using the schtasks command with minimal XML content to see if it imports successfully. This can help isolate whether the issue is with the XML or the command itself. 5. Manual Verification: Manually review the XML file to identify any discrepancies and ensure all elements are properly nested and closed. If you continue to face issues, feel free to share more details or the contents of the XML file here for further assistance.
 


Solution
Back
Top