【问题标题】:System.ComponentModel.Win32Exception c#System.ComponentModel.Win32Exception c#
【发布时间】:2020-04-30 09:49:19
【问题描述】:

这是我的代码:

    string damnfile = System.IO.Path.GetDirectoryName(choofdlog.FileName);
    ProcessStartInfo startInfo = new ProcessStartInfo("% ProgramFiles %\\Windows Defender\\MpCmdRun.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Maximized;
    startInfo.Arguments = "-Scan -ScanType 3 -File" + damnfile;
    Process p = new Process();
    p.StartInfo = startInfo;
    p.Start();

如您所见,我想对特定文件运行 WinDefender 扫描,但它会抛出找不到进程的错误,但此代码有效:

        ProcessStartInfo startInfo = new ProcessStartInfo("netstat");
        startInfo.WindowStyle = ProcessWindowStyle.Maximized;
        startInfo.Arguments = "-a";
        Process p = new Process();
        p.StartInfo = startInfo;
        p.Start();

我还想在第二个代码中将 cmd 输出重定向到 listBox,但这是第二个问题,请先帮我进行防御者扫描。

【问题讨论】:

    标签: c# visual-studio cmd process windows-defender


    【解决方案1】:

    像现在一样解决了,因为我替换了

     ProcessStartInfo startInfo = new ProcessStartInfo("% ProgramFiles %\\Windows Defender\\MpCmdRun.exe");
    

    ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\Program Files\\Windows Defender\\MpCmdRun.exe");
    

    现在出现了另一个问题:即使我传递了一些参数,窗口也会立即关闭。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-06
      • 2017-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多