system.com.ponentmodel.win32 exception启动过程 - 找不到文件,但文件存在



我正在尝试为我的AutoStart创建经理。它应该读取XML文件,然后以自定义延迟启动我的程序。例如:

<startup id="0">
    <name>Realtek Audio Manager</name>
    <process arguments="-s">C:Program FilesRealtekAudioHDARtkNGUI64.exe</process>
    <delay>5</delay>
</startup>

这将在5秒后运行指定的过程(C:Program Files...RtkNGUI64.exe -s)。

现在,三个程序将无法启动,给了我一个System.ComponentModel.Win32Exception:" Das System Kann Die Angebene Datei nicht finden。"("系统无法找到指定的文件。")

但是XML正确解析,我要启动的文件位于XML文件中指定的位置。

问题仅涉及这三个文件:
英特尔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文件, %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:WindowsSystem32igfxtray.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);
    }
}

显然您正在使用64位版本的Windows。C: Windows System32和C: Program Files Directories均受"文件系统重定向"的功能。这是一个AppCompat功能,有助于确保32位流程不会尝试使用64位可执行文件。他们会将重定向到C: Windows Syswow64和C: Program Files(x86)。

因此,当您尝试在C: Program Files Realtek etcetera中启动文件时,您的32位程序将被重定向到C: Program Files(X86) Realtek etceeta。不存在的目录,kaboom。igfxtray.exe

的相同成分

您需要更改程序的平台目标,以便它可以作为本机64位流程运行,并避免您现在遇到的重定向问题。项目 属性,构建选项卡,将"平台目标"设置更改为anycpu。

最新更新