I am trying to run the DJOIN command from C#. (It is present by default in the c:\windows\system32 directory on Win 10.)
When I run the following:
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = false;
psi.FileName = @"c:\windows\system32\djoin.exe";
psi.RedirectStandardOutput = true;
psi.Arguments = "/C toast";
using (Process proc = Process.Start(psi))
{
using (StreamReader reader = proc.StandardOutput)
{
string result = reader.ReadToEnd();
MessageBox.Show(result);
}
I get a "file not found" error:
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
Additional information: The system cannot find the file specified
However, if I use another "out of the box" .exe, such as "tasklist.exe" it works fine. E.g.:
proc.StartInfo.FileName = "tasklist.exe";
Gives me the following output: