这是创建可以调用 clickonce 应用程序的任务的示例代码:
using (TaskService ts = new TaskService())
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "runs clickonce app every 10 minutes";
var trigger = new TimeTrigger();
trigger.Repetition.Interval = TimeSpan.FromMinutes(10);
// Create a trigger that will fire the task at this time every other day
td.Triggers.Add(trigger);
// Create an action that will launch the clickonce app
td.Actions.Add(new ExecAction("rundll32.exe", @"dfshim.dll,ShOpenVerbApplication your_clickonce_app_url/clickonce_appname.application", null));
// Register the task in the root folder
ts.RootFolder.RegisterTaskDefinition(@"ClickOnce app", td);
}