System.ComponentModel.Win32Exception at process start - file not found, but file exists

I am trying to create a manager for my autorun. It should read the XML file and then run my programs with user delay. For example:

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

The specified process is executed ( C:\Program Files\...\RtkNGUI64.exe -s ) after 5 seconds.

Now three programs will not start, giving me System.ComponentModel.Win32Exception : "Das System kann die angegebene Datei nicht finden". ("The system could not find the specified file.")

But the XML is parsed correctly, and the file I want to run is in the location specified in the XML file.

The problem only applies to these three files:
Intel HotkeysCmd - C: \ Windows \ System32 \ hkcmd.exe
Intel GFX Tray - C: \ Windows \ System32 \ igfxtray.exe
Intel Persistance - C: \ Windows \ System32 \ igfxpers.exe

I think the problem is with the location of the files: they are all located in C: \ Windows \ System32, and all other working programs are located outside (C: \ Program Files, C: \ Program Files (x86), D: \ Program Files, %AppData% )

Do I have to give my program some permissions to run programs in C: \ Windows \ System32? How can I do it?

If not, why am I getting errors with these programs?

EDIT is my code:

 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); } } 
+7
source share
1 answer

Obviously, you are using a 64-bit version of Windows. The directories c: \ windows \ system32 and c: \ program files provide a feature called "file system redirection". This is the appcompat function, it helps to ensure that 32-bit processes will not try to use 64-bit executables. They will be redirected to c: \ windows \ syswow64 and c: \ program files (x86).

So, when you try to run the file in c: \ program files \ realtek \ etcetera, your 32-bit program will be redirected to c: \ program files (x86) \ realtek \ etcetera. A directory that does not exist is kaboom. Same ingredient for igfxtray.exe

You will need to change the target platform of your platform so that it can run as its own 64-bit process and avoid the redirection problem that you currently have. Project + Properties, Build, change the setting "Platform Target" to AnyCPU.

+16
source

All Articles