I'm trying to add a new task to the Windows Tasks Scheduler with schtasks.exe
. The problem I'm having now is to specify the day of the week at which the task should run.
From what I could find out that stupid program insists on getting that argument as string abbreviation of the day name - localized to the OS language.
Other parameters accepted the English strings just fine but supplying "SUN" on a German system doesn't work. How can I work around that?
If it were just an issue of supporting the couple of languages the application is translated in that wouldn't be bad. But this way I have to expect EVERY language that tool of a tool comes in...
I'm working in c# btw...
You could go over all days of the week (start with March 4th 2012, which is a Sunday, and move forward until Saturday, March 10th) and format that date using the ddd
format (short day name). That way you'll get all 7 short day names, based on your locale.
You can define your task in windows scheduler. Export the definition as XML(right click->export). Create a task using exported XML
schtasks /Create [/S <system> [/U <username> [/P [<password>]]]]
/XML <xmlfile> /TN <taskname>
The content of XML is language independent
来源:https://stackoverflow.com/questions/9530690/language-independent-way-to-specify-day-parameter-for-schtasks-exe