![](/img/trans.png)
[英]Getting an Exception System.ComponentModel.Win32Exception : The system cannot find the file specified in Sikuli C#
[英]system.componentmodel.win32exception = {“the system cannot find the file specified”} error when opening narrator from c# in window 7
我正在尝试使用C#在窗口7中打开“讲述人”屏幕阅读器
引发[system.componentmodel.win32exception] = {“系统找不到指定的文件”}异常。
我还写了一个程序来列出system32
目录中的所有.exe文件,它不显示讲述人。 为什么会发生这种情况,以及如何使用c#自动打开讲述人。
//尝试打开开幕叙述者引发异常
ProcessStartInfo narratorProcessInfo = new ProcessStartInfo();
try
{
Console.WriteLine("Starting Narrator");
Console.WriteLine("Opening time: " + DateTime.Now);
narratorProcessInfo.FileName = "C:\\Windows\\system32\\Narrator.exe";
using (Process narratorProcess = Process.Start(narratorProcessInfo))
{
narratorProcess.StartInfo.UseShellExecute = true;
Console.WriteLine("Waiting for 5 seconds");
Thread.Sleep(2000);
narratorProcess.Kill();
}
}
catch (Exception ex)
{
Console.WriteLine("The exception message: "+ ex);
}
Console.WriteLine("Press any key to exit");
Console.ReadLine();
//列出system32目录中的所有文件,但不显示旁白
Process pp = new Process();
try
{
string[] files = Directory.GetFiles(@"C:\Windows\System32"); // <-- Case-insensitive
// Display all BIN files.
Console.WriteLine("--- exe Files: ---");
foreach (string name in files)
{
Console.WriteLine(name);
Thread.Sleep(1000);
if (name.Contains("Narrator"))
{
pp.StartInfo.FileName = name;
pp.Start();
Console.WriteLine("Waiting 5 sec");
Thread.Sleep(5000);
break;
}
}
}
catch (Exception ex)
{
Console.WriteLine("The exception message: " + ex);
}
Console.WriteLine("Press any key to exit");
Console.ReadLine();
据我所知,当您尝试直接访问C#中的System32
进程时,在后台发生了重定向。 您需要关闭WOW重定向,以防止启动系统进程。
试试此链接,看看是否对您有帮助: C#中的WOW重定向停用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.