Hi,
I want to launch from a button in a Windows Form this command:
private void buttonGenerateKey_Click(object sender, EventArgs e)
{
var workingDir = @"C:\Users\me\Desktop\MyApp\key";
Directory.CreateDirectory(workingDir);
Process process = new Process();
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.FileName = @"C:\Windows\System32\OpenSSH\ssh-keygen.exe";
process.StartInfo.Arguments = $"-t ecdsa -b 256 -m pem -N password123 -f \"{Path.Combine(workingDir, "new_ecdsa")}\"";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.WaitForExit();
process.Close();
}
But, when I click on this button (buttonGenerateKey), an exception occurs: Cannot find specified file: System.ComponentModel.Win32Exception (0x80004005): Cannot find specified file.
in System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
...
the line number is the one corresponding to process.StartInfo.FileName = ....
my App is running as administrator so there shouldn't be any privilege issues. And ssh-keygen.exe exists in C:\Windows\System32\OpenSSH (I've installed OpenSSH).
How I can solve this? I've already tried to:
- Delete the path before ssh-keygen.exe
- Copy ssh-keygen.exe in my working dir
But nothing goes right.
Thank you.