日期:2014-05-18  浏览次数:20932 次

Winform中如何打开windows任务计划的文件夹,知道的请进!
RT,想通过代码打开任务计划文件夹,但是不知道该应用程序在C盘的哪个文件夹下,网上查询得到的是system32底下的schtasks.exe,但是打开后直接自动关闭,浏览不了计划,而且显示的dos窗口。请问有人知道怎么打开吗,像通过控制面板打开显示的界面

------解决方案--------------------
private void OpenShellApplication(string FileName)
{
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
Info.FileName = FileName;
System.Diagnostics.Process Proc;
try
{
Proc = System.Diagnostics.Process.Start(Info);
}
catch
{
MessageBox.Show("系统调用[" + FileName + "]应用程序出错!");
}
}
------解决方案--------------------
好像这样是可以的
public void button1_Click(object sender, EventArgs e)
{
//using Microsoft.Win32.TaskScheduler;
DataTable schedTable = new DataTable();
schedTable.Columns.Add(new DataColumn("Name", typeof(string)));
schedTable.Columns.Add(new DataColumn("Schedule", typeof(string)));
schedTable.Columns.Add(new DataColumn("Next", typeof(DateTime)));
schedTable.Columns.Add(new DataColumn("Last", typeof(DateTime)));
schedTable.Columns.Add(new DataColumn("Status", typeof(Enum)));
schedTable.Columns.Add(new DataColumn("Enabled", typeof(Boolean)));
schedTable.Columns.Add(new DataColumn("Description", typeof(string)));

List<Task> tasks = new List<Task>();
using (TaskService ts = new TaskService())
{

Version ver = ts.HighestSupportedVersion;
bool newVer = (ver >= new Version(1, 2));

// Output all the tasks in the root folder with their triggers and actions
TaskFolder tf = ts.RootFolder;
foreach (Task t in tf.Tasks)
{
tasks.Add(t);
string trStr = "";
DataRow r = schedTable.NewRow();
try
{
this.textBox1.AppendText(t.Name + Environment.NewLine);
r["Name"] = t.Name;
foreach (Trigger tr in t.Definition.Triggers)
{
if (trStr != "")
trStr += ";";
trStr += tr.ToString();
}
r["Schedule"] = trStr;
r["Next"] = t.NextRunTime;
r["Last"] = t.LastRunTime;
r["Status"] = t.State;
r["Enabled"] = t.Enabled;
r["Description"] = t.Definition.RegistrationInfo.Description;
schedTable.Rows.Add(r);
}
catch { }
}
}
}

需要引入 Microsoft.Win32.TaskScheduler.dll
下载地址
http://taskscheduler.codeplex.com/releases/view/73297
------解决方案--------------------
这种特殊的文件夹是有classid的。好像是{D6277990-4C6A-11CF-8D87-00AA0060F5BF}。然后利用它应该就可以打开。但我不知道怎么做。。。

而且你是在XP上开发吧,win7的计划任务是个程序而不是文件夹了。