You can also use ShellExecute
This test works for me, with hardcoded paths for testing (x86 on Windows 10 64) :
BOOL bWow64 = false;
IsWow64Process(GetCurrentProcess(), &bWow64);
if (bWow64)
{
PVOID OldValue = NULL;
if (Wow64DisableWow64FsRedirection(&OldValue))
{
}
}
HINSTANCE h = ShellExecute(NULL, NULL, L"cmd.exe", L"/c C:\\Windows\\System32\\OpenSSH\\ssh.exe -Q key > c:\\temp\\output.txt", NULL, SW_SHOWNORMAL);