Aw: Re: How to detect if a file is executable on Windows?

Karsten Hilbert Karsten.Hilbert at gmx.net
Tue Feb 19 14:03:06 EST 2019


> I guess you have to define the question better for Windows, since
> there's no single definition of "executable". If you mean "typing just
> the base name of this file at the shell will result in it being run",
> then PATHEXT is the correct answer. If you mean "this thing is
> actually inherently executable", then you probably want to check if it
> begins MZ, but that's not certain (COM files still seem to be
> supported, and they have no header whatsoever). If you mean
> "double-clicking this thing will run it", I think there are tools that
> allow you to do the registry lookup conveniently to see if something's
> associated.

As far as that goes, pretty much the same is true for UNIX (sans
the registry thingy, unless you count in binfmt for that).

The executable flag doesn't mean it is actually executable, only
that it is meant to, and that the kernel is supposed to try.

Karsten



More information about the Python-list mailing list