0
I created a task in MS Task Scheduler app using simple xml command approach:
SCHTASKS /CREATE /SC DAILY /TN "TEST" /XML "C:\TEST.xml"
When I try to register the task in an Arabic regional OS setting/machine the task registration fails.
- Failed command_prompt (image):
XML (task):
<Task version="1.2" xmlns="...">
<RegistrationInfo>
<Date>1441-04-07T11:33:39</Date>
<URI>TEST</URI>
</RegistrationInfo>
<Triggers>
<TimeTrigger>
<StartBoundary>1441-04-07T11:33:39-08:00</StartBoundary>
..
But, if I edit the date in this Xml to our default 2019 (en-US based calendar) instead of that Arabic (Hijri calendar) year 1441, the task registers successfully:
- Success command_prompt (image):
<Task version="1.2" xmlns="...">
<RegistrationInfo>
<Date>2019-04-12T11:33:39</Date>
<URI>TEST</URI>
</RegistrationInfo>
<Triggers>
<TimeTrigger>
<StartBoundary>2019-04-12T11:33:39-08:00</StartBoundary>
..
I am using this command from a Wpf UI application so I cannot put non-localized date format in it. Please let me know how to register this task in that localized machine! Thanks a lot.
What locale is Windows configured to use? What calendar is Windows using? Edit your question, do not submit commentary, when you provide this information. – Ramhound – 2019-12-05T01:54:09.350
Your likely using the incorrect Task schema – Ramhound – 2019-12-05T02:04:53.503
@Ramhound: Thanks for the reply. The windows is ar-DZ locale. I think arabic calendar is Hijri! – Joe – 2019-12-05T04:13:29.260
Why didn’t you edit your question? Are you sure the DateTime string is properly formatted for your particular CultureInfo? – Ramhound – 2019-12-05T04:17:05.417
Which commentary, the xml tags you mean!? My xml is proper, i think, as it is working for all other locales (english calendars) except hebrew and arabic. – Joe – 2019-12-05T04:25:34.033
@Ramhound: I used dtNow.ToString("yyyy-MM-ddTHH:mm:ssK") as the Date/StartBoundary tag's value. This seems to be the problem as it is acts as an irrelevant year format for this locale/os. – Joe – 2019-12-05T04:50:25.163
Which is exactly what I asked. Since I do not read or speak Arabic, your going to have to determine, what the proper CultureInfo format is exactly. Isn’t Arabic and Hebrew Right to Left languages? I would use DateTime.To*** methods using the appropriate calendar to determine what the proper format should be. – Ramhound – 2019-12-05T04:54:47.653
Yes, these languages are RTL. Its pretty tricky, at times, to debug them that way :-). I will try to do use the ToString overloads. Much thanks for your time. – Joe – 2019-12-05T04:58:27.177