How to detect if a file is executable on Windows?
And based on a determinist solution?
Yes, you can check the extension but sometimes I prefer to be sure.
For example, the API of Win32 has the GetTypeBinaryW function, this one
could be used but I need to create a mapping, with CPython api, ctypes
I could also use the 2 first bytes of a file and determine if the file
is a binary because on Windows, the executable files start with b'MZ'.
But I wanted an elegant and minimalist solution.
Thank you for your proposal.
Have a nice day,
On 02/18, Igor Korot wrote:
>On Tue, Feb 19, 2019 at 7:26 AM Stephane Wirtel <stephane at wirtel.be> wrote:
>> Hi all,
>> on Linux/Unix/BSD, we can detect if a file is an executable with
>> os.access(path, os.X_OK) but this is not the case on Windows.
>> Do you have an idea?
>Check file extension?
>> Have a nice day,
>> St?phane Wirtel - https://wirtel.be - @matrixise
St?phane Wirtel - https://wirtel.be - @matrixise