It's not working because you application is 32 bit and is being affected by the File System Redirector. Your application is not looking in C:\Windows\System32
but is instead being redirected to C:\Windows\SysWow64
.
notepad.exe
exists in both System32
and SysWow64
, but telnet.exe
only exists in System32
. So you application does not find it when it searches the path.
You can disable this behavior for your application by calling Wow64DisasbleWow64FsRedirection. But note the warnings in the documentation links that indicate that this should only be disabled temporarily and then re-enabled.