Search code examples
.netlocalizationcommandwindows-task-scheduler

Task arguments doesn't accept localized strings, and the task fails with File Not Found error


I created a task in MS Task Scheduler app using simple xml command approach:

SCHTASKS /CREATE /SC DAILY /TN "*Hebrew Localized Name Here*" /XML "C:\TEST.xml"

This xml has the arguments string (to run a file) with a localized (hebrew/arabic) path name like this:

...    
 <Exec>
      <Command>"C:\fold\pythonw.exe"</Command>
      <Arguments>"C:\Hebrew_Localized_folder_here\script.py"</Arguments> 
 </Exec>    
...

BUT, finally the file path(Arguments here) added to scheduler ui shows irrelevant characters (like, ان تمام آزادیوں اور حقوق ک), and the task fails to execute.

Task Scheduler task's property (image)

Anyone had similar issue!?


Solution

  • Reference link: why does the Xdocument give me a utf16 declaration?

    So using

    doc.Save(xmlfilePath);
    

    instead of File.WriteAllText(xmlfilePath, doc.ToString()); to save my edited xml helped resolving the localization issue.