private void RefreshAutoStartButtonStatus() { if (!string.IsNullOrEmpty(getTaskName())) { tsbtnAutoStart.Checked = TaskSchedulerHelpers.IsExist(getTaskName()); } }
private void tsbtnAutoStart_Click(object sender, EventArgs e) { if (!File.Exists(this.txtExeFile.Text)) { MessageBox.Show("请先填写执行程序路径!"); return; } if (tsbtnAutoStart.Checked) { TaskSchedulerHelpers.DeleteTask(getTaskName()); } else { TaskSchedulerHelpers.SetAutoStartup(getTaskName(), Assembly.GetEntryAssembly().Location); } RefreshAutoStartButtonStatus(); }