【发布时间】:2018-10-23 15:53:18
【问题描述】:
我有一个 C# 程序,它启动一个子进程并将其输出捕获到一个字符串中。这适用于大多数 Windows 机器(Windows 7 和更新版本),但当存在卡巴斯基反病毒软件时,Process.StandardOutput.ReadToEnd() 返回null。没有错误代码或异常。子进程是受信任的控制台应用程序。该过程需要 5 或 6 秒才能运行。
启动子进程的代码如下:
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.FileName = "icao.exe";
psi.Arguments = im_path + "image.jpg";
Process p = new Process();
p.StartInfo = psi;
p.Start();
string output = p.StandardOutput.ReadToEnd();
string error = p.StandardError.ReadToEnd();
MessageBox.Show(error);
p.WaitForExit();
int exitCode = p.ExitCode;
MessageBox.Show(exitCode+"");
当卡巴斯基在场时,为什么output 最终会变成null?
【问题讨论】:
-
你为什么把它标记为 C++?
-
因为c#程序执行dlib c++例子
-
您的问题有点难以理解。你是说当这个程序在安装了卡巴斯基的系统上运行时输出和/或错误为空?
-
是的。我检查了这两个程序,没有病毒迹象。
-
从 AV 中排除可执行文件,它可以工作吗?