启动“DOS”程序时如何避免 Windows (XP) 安全警告C# 中的命令行?
这个问题与不久前提出的这个初始问题相关。
现在,我已经选择了提取工具,我正在迭代命令行参数目录和子目录中给定的目录来提取压缩的 .zip 文件。
private static void ExtractAll(DirectoryInfo _workingFolder) {
if(_workingFolder == null) {
Console.WriteLine("Répertoire inexistant.");
return;
}
foreach (DirectoryInfo subFolder in _workingFolder.GetDirectories("*", SearchOption.AllDirectories))
foreach(FileInfo zippedFile in subFolder.GetFiles("*.zip", SearchOption.AllDirectories)) {
if(zippedFile.Exists) {
ProcessStartInfo task = new ProcessStartInfo(@".\Tools\7za.exe", string.Format("x {0}", zippedFile.FullName));
Process.Start(task);
}
}
}
但每次启动7za进程时,都会出现Windows安全警告提示。我想避免这种烦人的行为,所以这是我的问题:
在 C# 中启动“DOS”命令行时如何避免 Windows (XP) 安全警告?
This question is related to this initial question asked a little while ago.
Now, that I have chosen the extracting tool, I'm iterating through a given in command line parameter directory and subdirectories to extract the compressed .zip files.
private static void ExtractAll(DirectoryInfo _workingFolder) {
if(_workingFolder == null) {
Console.WriteLine("Répertoire inexistant.");
return;
}
foreach (DirectoryInfo subFolder in _workingFolder.GetDirectories("*", SearchOption.AllDirectories))
foreach(FileInfo zippedFile in subFolder.GetFiles("*.zip", SearchOption.AllDirectories)) {
if(zippedFile.Exists) {
ProcessStartInfo task = new ProcessStartInfo(@".\Tools\7za.exe", string.Format("x {0}", zippedFile.FullName));
Process.Start(task);
}
}
}
But everytime I start a 7za process, the Windows Security Warning prompts. I would like to avoid such annoying behaviour, so here's my question:
How to avoid the Windows (XP) Security Warning when launching a "DOS" command line within C#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这充其量只是一个猜测(没有时间尝试),但也许尝试使用 CreateNoWindow?
http://msdn.microsoft.com/en- us/library/system.diagnostics.processstartinfo.createnowindow.aspx
这是使用建议的解决方案后的代码:
This is a guess at best(don't have the time to try), but maybe try using CreateNoWindow?
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.createnowindow.aspx
Here's the code after using the proposed solution: