C#读取注册表,C#创建任务计划

string tPath = "";

RegistryKey myKey = Registry.LocalMachine;

RegistryKey subKey = myKey.OpenSubKey(@"SOFTWARE\DSCCheck");

tPath = subKey.GetValue("path").ToString();

tPath = tPath + @"\" + "Test.exe";

说明:其中(@"SOFTWARE\DSCCheck")代表需要读取的文件在注册表中的路径

下面是将Test.exe文件添加到任务计划中,定时执行 DSCTasks.DscTask cTask = new DSCTasks.DscTask();

Hashtable htWork = new Hashtable();

DailyTrigger tdaily = new DailyTrigger(tHour, tMintue, 1);//設置系統執行時間

tdaily.BeginDate = dtBeginDate;//开始执行时间

tdaily.EndDate = dtEndDate;//结束执行时间

htWork.Add(htWork.Count, tdaily);//加入到任务计划执行中

cTask.CreateTask("DSCCheck", tPath, htWork);//创建任务计划

转载于:https://www.cnblogs.com/zhangchenliang/archive/2010/09/09/1822130.html

猜你喜欢

转载自blog.csdn.net/weixin_34404393/article/details/93496051