mirror of
https://github.com/microsoft/PowerToys
synced 2024-11-22 00:03:48 +00:00
62 lines
1.6 KiB
C#
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.";
|
|
}
|
|
}
|
|
}
|
|
}
|