PowerToys/WinAlfred.Plugin.System/CMD.cs

62 lines
1.6 KiB
C#
Raw Normal View History

2014-01-03 18:16:05 +08:00
using System;
using System.Collections.Generic;
2014-01-03 23:52:36 +08:00
using System.Diagnostics;
2014-01-03 18:16:05 +08:00
using System.Linq;
using System.Text;
2014-01-03 23:52:36 +08:00
using System.Windows.Forms;
2014-01-03 18:16:05 +08:00
namespace WinAlfred.Plugin.System
{
2014-01-03 23:52:36 +08:00
public class CMD : ISystemPlugin
2014-01-03 18:16:05 +08:00
{
public List<Result> Query(Query query)
{
2014-01-03 23:52:36 +08:00
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();
2014-01-04 20:26:13 +08:00
ProcessStartInfo startInfo = new ProcessStartInfo
{
WindowStyle = ProcessWindowStyle.Normal,
FileName = "cmd.exe",
Arguments = "/C " + cmd
};
2014-01-03 23:52:36 +08:00
process.StartInfo = startInfo;
process.Start();
}
};
results.Add(result);
}
return results;
2014-01-03 18:16:05 +08:00
}
2014-01-03 23:52:36 +08:00
public void Init(PluginInitContext context)
2014-01-03 18:16:05 +08:00
{
2014-01-03 23:52:36 +08:00
}
public string Name
{
get
{
return "CMD";
}
}
public string Description
{
get
{
return "Execute shell commands.";
}
2014-01-03 18:16:05 +08:00
}
}
}