如何在启动“DOS”时避免Windows(XP)安全警告。命令行在C#中?
这个问题与这个初始问题有关。 。
现在,我已经选择了提取工具,我通过一个给定的命令行参数目录和子目录中提取压缩的.zip文件。 p>
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);
}
}
}
但每次我开始一个7za进程,Windows安全警告提示。我想避免这种恼人的行为,所以这里是我的问题:
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:
如何避免Windows(XP)安全警告启动DOS命令行
这是最好的猜测(没有时间去尝试)也许可以尝试使用CreateNoWindow?
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:
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) {
Console.WriteLine(string.Format("Extraction du fichier : {0}", zippedFile.FullName));
Process task = new Process();
task.StartInfo.UseShellExecute = false;
task.StartInfo.FileName = @".\Tools\7za.exe";
task.StartInfo.Arguments = string.Format("x {0}", zippedFile.FullName);
task.StartInfo.CreateNoWindow = true;
task.Start();
Console.WriteLine(string.Format("Extraction de {0} terminée", zippedFile.FullName));
//ProcessStartInfo task = new ProcessStartInfo(@".\Tools\7za.exe", string.Format("x {0}", zippedFile.FullName));
//Process.Start(task);
}
}
}