Please do not mark as Duplicate : I know that executable files such us .exe are a set of instructions in machine language (binary) but what I don't know if those instruction are targeted to the system (then to the kernel) and then to the CPU or they're read from the memory directly by the CPU ? I'm a bit confused
Arranging for executable files to run is done by the process loader, usually a part of, or executed by, the UI shell.
The exe file contains header metadata and executable code.
The loader reads the executable file header, allocates an initial working set of kernel and other resources that a process will need to run and creates a thread to run code at the process entry point. If that code has not been read into memory by the loader, it will happen now in an immediate page pault loads it.
The process then exists, and a thread is running it.
Summary: the image file, (.exe in Wondows), contains both metadata for interpretation by the OS loader AND executable code. The executable code instructions are read into memory by the loader and the CPU fetches and executes those instructions from memory.