coming from the * nix world, I am very confused with the behavior of Windows and probably with its security system.
I am just trying to execute an external program in my application. I found a WinExI ShellExecute function that works as expected, except for running some programs hosted in the% windir% \ System32 subdirectory.
Running ping.exe successfully
ShellExecute(NULL, "open", "c:\\Windows\\System32\\ping.exe', NULL, NULL, SW_SHOW) ); // ^^^ OK, retcode == 42
Java.exe execution not working
ShellExecute(NULL, "open", "c:\\Windows\\System32\\java.exe', NULL, NULL, SW_SHOW) ); // ^^^ ERROR_FILE_NOT_FOUND, retcode == 2
This is very strange because java.exe exists in System32 , has read / execute permissions for the Users group, and can be called from cmd.
C:\>dir /qc:\Windows\System32\java.exe Volume in drive C has no label. Volume Serial Number is 56E3-0868 Directory of c:\Windows\System32 11.01.2012 23:40 172 320 NT AUTHORITY\SYSTEM java.exe 1 File(s) 172 320 bytes 0 Dir(s) 226 127 564 800 bytes free C:\>cacls c:\Windows\System32\java.exe c:\Windows\System32\java.exe NT AUTHORITY\SYSTEM:F BUILTIN\Administrators:F BUILTIN\Users:R
What am I missing here?
OS is Windows 7 Home Edition.
Update:. If I copy c: \ Windows \ Sytem32 \ calc.exe to c: \ Windows \ Sytem32 \ calc2.exe, ShellExecute can run the original calc.exe file, but with the error calc2.exe, although the files are identical! The only difference is the additional permissions for the TrustedInstaller group, in which calc2.exe and java.exe are missing. Coincidence?
source share