BCDEDIT not recognized when running via C#
c#, windows
Solution
There is one explanation that makes sense:
- You are executing the program on a 64 bit machine.
- Your C# program is built as x86.
- The `bcdedit.exe` file exists in `C:\Windows\System32`.
- Although `C:\Windows\System32` is on your system path, in an x86 process you are subject to the File System Redirector. Which means that `C:\Windows\System32` actually resolves to `C:\Windows\SysWOW64`.
- There is no 32 bit version of `bcdedit.exe` in `C:\Windows\SysWOW64`.
The solution is to change your C# program to target `AnyCPU` or `x64`.
Problem
When i try to run BCDEDIT from my C# application i get the following error: 'bcdedit' is not recognized as an internal or external command, operable program or batch file. when i run it via elevated command line i get as expected. i have used the following code: ``` Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.FileName = @"CMD.EXE"; p.StartInfo.Arguments = @"/C bcdedit"; p.Start(); string output = p.StandardOutput.ReadToEnd(); String error = p.StandardError.ReadToEnd(); p.WaitForExit(); return output; ``` i have also tried using ``` p.StartInfo.FileName = @"BCDEDIT.EXE"; p.StartInfo.Arguments = @""; ``` i have tried the following: - Checking path variables - they are fine. - running visual studio from elevated command prompt. - placing full path. i am running out of ideas, any idea as to why i am getting this error ? all i need is the output of the command if there is another way that would work as well. thanks