Language independent way to specify day parameter for schtasks.exe

我只是一个虾纸丫 提交于 2019-12-07 11:14:49

问题


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...


回答1:


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.




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!