I am trying to execute c:\windows\system32\rdpclip.exe from my Delphi program (Delphi CE 10.4) on Windows 10.
I can see and execute this file just fine from Windows Explorer or from a CMD window, but when I try to use FileExists('c:\windows\system32\rdpclip.exe') it comes back with error 2 (file not found). If I use ShellExecute() to start it, I get file not found as well.
I can see and execute c:\windows\system32\cmd.exe from my Delphi code just fine. No special attributes are set on rdpclip.exe - they are the same as those on cmd.exe. The user ID is a member of local administrators, and UAC control is set to "Disable" running all admins in admin approval mode.
I also found that if I list the contents of the c:\windows\system32 folder using FindFirst()/FindNext(), a lot of files (including rdpclip.exe) are not listed, while others are (for example, rdpsa.exe shows up in the list, while rdpclip.exe does not).
rdpclip.exe shows up in File Explorer, and can be started manually from the "Run" prompt in Windows. It is NOT visible in my Delphi program using ShellExecute() or FindFirst()/FindNext().
Other files in the same folder (cmd.exe, rdpsa.exe) are visible, and can be executed from the same Delphi program, using the same line of code (just changing the file name).
The expectation was, of course, that my Delphi program would behave the same way as File Explorer in Windows behaves.
File attributes are no different on all of those files, and effective access control shows that the current user has read/execute to all of the files in question.
The reason why your program is not finding
rdpclip.exefile is beacuse on 64 bit version of windows folderWindows\System32doesn't actually hold any 32 bit libraries or programs as one might expect but instead it contains all 64 bit libraries and programs.32 bit libraries and programs can actually be located in
Windows\SysWOW64folder instead. So when any 32 bit application is trying to accessSystem32folder it is automatically redirected intoSys64WOWfolder. And if you check theSys64WOWfolder you will see that there is nordpclip.exefile located there.I recommend you read more about File System Redirector to better understand your problem.
EDIT: You can avoid
System32folder redirection by usingSysnativeas it is explained in Could not find system file when it actually exists