【发布时间】:2012-12-08 02:52:18
【问题描述】:
我正在尝试为我的自动启动创建一个管理器。它应该读取一个 XML 文件,然后以自定义延迟启动我的程序。例如:
<startup id="0">
<name>Realtek Audio Manager</name>
<process arguments="-s">C:\Program Files\Realtek\Audio\HDA\RtkNGUI64.exe</process>
<delay>5</delay>
</startup>
这会在 5 秒后运行指定的进程 (C:\Program Files\...\RtkNGUI64.exe -s)。
现在,三个程序无法启动,给我一个System.ComponentModel.Win32Exception:“Das System kann die angegebene Datei nicht finden。” ("系统找不到指定的文件。")
但是XML解析正确,我要启动的文件在我在XML文件中指定的位置。
问题只涉及这三个文件:
Intel HotkeysCmd - C:\Windows\System32\hkcmd.exe
英特尔 GFX 托盘 - C:\Windows\System32\igfxtray.exe
英特尔持久性 - C:\Windows\System32\igfxpers.exe
我认为问题出在文件的位置:它们都位于 C:\Windows\System32 中,而所有其他工作程序都位于外部(C:\Program Files、C:\Program Files (x86), D:\Program Files, %AppData%)
我是否必须授予我的程序某种访问权限才能在 C:\Windows\System32 中启动程序?我该怎么做?
如果不是,我在这些程序中出现错误的原因可能是什么?
编辑 - 我的代码:
delegate(object o)
{
var s = (Startup) o;
var p = new System.Diagnostics.Process
{
StartInfo =
new System.Diagnostics.ProcessStartInfo(s.Process, s.Arguments)
};
try
{
s.Process = @"C:\Windows\System32\igfxtray.exe"; // For debugging purposes
System.Diagnostics.Process.Start(s.Process);
icon.ShowBalloonTip(2000, "StartupManager",
"\"" + s.Name + "\" has been started.",
System.Windows.Forms.ToolTipIcon.Info);
}
catch (System.ComponentModel.Win32Exception)
{
icon.ShowBalloonTip(2000, "StartupManager",
"\"" + s.Name + "\" could not be found.",
System.Windows.Forms.ToolTipIcon.Error);
}
}
【问题讨论】:
-
你有没有试过只是在做:System.Diagnostics.Process.Start(@"C:\Windows\System32\igfxtray.exe");我试过了(我的机器上有 igfxtray),完全没有错误。
-
您使用的行也适用于我,但是当我使用变量 (
System.Diagnostics.Process.Start(s.Process))(其中 s 是包含string Process的struct Startup)时,它就无法启动,虽然s.Process == "C:\\Windows\\System32\\igfxtray.exe". -
可以禁用。在这里解决了:stackoverflow.com/questions/17487653/…
标签: c# exception file-access file-not-found win32exception