c# 实现操作系统 “运行” 功能

void Main()
{
    var psi = new ProcessStartInfo();
    psi.FileName = "cmd.exe";
    psi.Arguments = "/c start /ABOVENORMAL notepad \"c:\\abc.txt\"";
    psi.CreateNoWindow = true;
    psi.UseShellExecute = false;
    psi.RedirectStandardOutput = true;
    Process.Start(psi);
}

 如果要隐藏的运行则用以下代码:

var cmd = "taskkill /pid 62084";
    var psi = new ProcessStartInfo();
    psi.FileName = "cmd.exe";
    psi.Arguments = "/c start /B " + cmd;
    psi.CreateNoWindow = true;
    psi.UseShellExecute = false;
    psi.RedirectStandardOutput = true;
    Process.Start(psi);

 

posted on 2021-05-29 16:23  空明流光  阅读(150)  评论(0编辑  收藏  举报

导航