"The task XML is missing a required element or attribute" error when you use the /z switch together with the Schtasks command in Windows Vista


Symptoms


When you use the /z switch together with the Schtasks.exe command in Windows Vista, you may receive the following error message:

Error: The task XML is missing a required element or attribute. 

The /z switch is used to delete a task after it is completed. For example, you can use the following command to start the Calc.exe process at a specified date and time:

schtasks /create /tn "calculator" /tr c:\Windows\System32\calc.exe /sc once /sd 12/02/2010 /st 03:39:00 /z

Note This issue affects only the Schtasks.exe tool. You should be able to use the Scheduled Tasks interface to auto-delete a task after it is completed.

Cause


This issue occurs because of changes in the Task Scheduler service in Windows Vista.

Resolution


To resolve this issue, use the /V1 switch. The /V1 switch creates a task that is compatible with pre-Windows Vista platforms. For example, use the following command to start the Calc.exe process at a specified date and time in a pre-Windows Vista environment:

schtasks /create /tn "calculator" /tr c:\Windows\System32\calc.exe /sc once /sd 12/02/2010 /st 03:39:00 /V1 /Z

More Information


For more information about the /V1 switch, visit the following MSDN website:

http://msdn2.microsoft.com/en-us/library/bb736357(VS.85).aspx