'Ksetup.exe' tool is used to configure a KDC server in a windows machine; Link1, Link2;
This tool is present in 'C:\Windows\System32\' location; Find the ;
This can be executed in a command prompt directly to get the result of installed KDC in the machine; (Check the image)!
I need to execute this command programmatically via C#; I tried using ProcessInfo class with below code; But I couldn't get the result only for this command; I mean I can able to get result of all other command I tried (like ipconfig, hostname,.)
ProcessStartInfo startInfo = new ProcessStartInfo("cmd", "/c ksetup")
{
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
WorkingDirectory = @"C:\Windows\System32"
};
Process p = Process.Start(startInfo);
p.Start();
p.WaitForExit();
When I execute the same I get output message like this,
"'ksetup' is not recognized as an internal or external command,\r\noperable program or batch file."
What is the change I need in my code to execute the command?
Edit - With a workaround solution
This issue occurs because we try to access a file belonging to "C:\Windows\System32" directory;
Later I just copied the file and placed in "C:\Windows\ksetup.exe" location and it worked;
Other references: Why do 64-bit DLLs go to System32 and 32-bit DLLs to SysWoW64 on 64-bit Windows?
Another solution is, unchecking "Prefer 32 bit option" in build tab of project's properties window;
So my question is can't we access files/command present in "C:\Windows\System32" location programatically?