PowerToys/WinAlfred.Plugin.System/CMD.cs
2014-01-04 20:26:13 +08:00

62 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WinAlfred.Plugin.System
{
public class CMD : ISystemPlugin
{
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
if (query.RawQuery.StartsWith(">") && query.RawQuery.Length > 1)
{
string cmd = query.RawQuery.Substring(1);
Result result = new Result
{
Title = cmd,
SubTitle = "execute command through command shell" ,
IcoPath = "Images/cmd.png",
Action = () =>
{
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
WindowStyle = ProcessWindowStyle.Normal,
FileName = "cmd.exe",
Arguments = "/C " + cmd
};
process.StartInfo = startInfo;
process.Start();
}
};
results.Add(result);
}
return results;
}
public void Init(PluginInitContext context)
{
}
public string Name
{
get
{
return "CMD";
}
}
public string Description
{
get
{
return "Execute shell commands.";
}
}
}
}