Search code examples
c#wpfvisual-studio-2019

System.ComponentModel.Win32Exception: Path not found


In my WPF Application i can use this command:

Process.Start(@"C:\Windows\System32\appwiz.cpl");

But this is not working:

Process.Start(@"C:\Windows\System32\firewall.cpl");

i got (in german): System.ComponentModel.Win32Exception: "Das System kann die angegebene Datei nicht finden". File not found. But when i put C:\Windows\System32\firewall.cpl to my file Explorer, Firewall.cpl is opening. I tryed some others:

OK:

  • desk.cpl
  • hdwwiz.cpl
  • inetcpl.cpl
  • intl.cpl
  • joy.cpl
  • main.cpl
  • mmsys.cpl

NOK:

  • Firewall.cpl
  • igfxCPL.cpl
  • compmgmtlauncher.exe

What ist the Problem?


Solution

  • According to the comments,the solution is c:\windows\sysnative\firewall.cpl or Project > Properties > Build tab, "Prefer 32-bit" unticked.

    https://learn.microsoft.com/en-us/windows/win32/winprog64/file-system-redirector

    You can also refer to the two answers under this link.

    how do i link my windows form with .NET framework to steam without build errors