【发布时间】:2012-04-03 12:43:09
【问题描述】:
我已经使用 Process 类创建了一个进程。现在我需要限制所有这些新进程可以访问的内容,例如访问 Internet、l 或特殊目录的权限。 如何做呢。 到目前为止我的代码是这样的。
Process p = new Process()
{
StartInfo = new ProcessStartInfo(executablePath) {
CreateNoWindow = true,
ErrorDialog = false,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
WindowStyle = ProcessWindowStyle.Hidden,
StandardErrorEncoding = Encoding.UTF8,
StandardOutputEncoding = Encoding.UTF8,
UseShellExecute = false,
}
};
p.Start();
var outputStreamReader = p.StandardOutput;
var inputStreamWriter = p.StandardInput;
var errorStreamReader = p.StandardError;
p.WaitForExit();
string output = outputStreamReader.ReadToEnd();
string s = "";
【问题讨论】:
-
如果输出流被填满,您的代码可能会在
p.WaitForExit()上死锁。 -
是的.. 我错过了。感谢您指出这一点。但考虑到我不会通过这个过程获得那么多数据。我不认为这是一个问题
-
它是 .net 进程吗?是你的还是第三者的。你这样做是否在范围内。应该由用户/管理员来施加这种安全限制。
-
执行 wud 的路径是在运行时决定的,它将是其他一些控制台应用程序,但它将运行的系统是我的,而且代码是我的。
标签: .net security c#-4.0 process