我正在尝试添加计划任务
schtasks /create /tn bla /tn "c:\blabla.exe" /st 04:00:00 /sd 01/01/2011 /sc daily
这在英语版本上有效。但是,当我尝试在德语系统上启动该命令时,它需要选项/sc täglich
而不是/sc daily
。
有没有办法改变该命令以便它可以在每种语言环境中运行?
答案1
我现在正在用 C# 做这件事。
using (TaskService ts = new TaskService())
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";
td.Principal.LogonType = TaskLogonType.InteractiveToken;
// Run the service every hour.
var tt = new TimeTrigger();
tt.Repetition.Interval = TimeSpan.FromDays(1);
tt.StartBoundary = DateTime.Today;
td.Triggers.Add(tt);
// Add an action that will launch someProgram.exe whenever the trigger fires
td.Actions.Add(new ExecAction("c:\example.exe", null, null));
// Register the task in the root folder
const string taskName = "ExampleTask";
ts.RootFolder.RegisterTaskDefinition(taskName, td);
// Remove the task we just created
// ts.RootFolder.DeleteTask(taskName);
}