php.exe is not a valid win32 application. Access Denied

Recently, I needed to run php from the command line on Windows. I had php in my PATH but when I ran the command, an alert window popped up saying “php.exe is not a valid win32 application.”. In my terminal / command line, the response I got was “Access Denied.” Somehow, the php.exe file size become 0 bytes. To fix this, I just overwrote that file with the original php.exe file (60 KB) and reran the command and it worked.

If you get this error, check the file size of your exe.