Running .NET programs under Windows PE

Windows PE can be modified to include PowerShell as well as .NET like described here:

https://msdn.microsoft.com/en-us/windows/hardware/commercialize/manufacture/desktop/winpe-adding-powershell-support-to-windows-pe

 

Windows PE is limited to running one type of executable (either x86, AMD64 or ARM), depending on the type of Windows PE image.

This also affects .NET applications.

 

.NET programs compiled for any CPU may fail on AMD64 versions of Windows PE with:

The subsystem needed to support the image type is not present.

 

This can happen if the “Prefer 32-bit” build option is set, which is the default for some project types with Visual Studio 2015.

 

The solution is either to remove the “Prefer 32-bit” option before compiling.

vs_build_deselect_prefer_32-bit

 

Or using corflags to remove any 32-bit flags with:

corflags program.exe /32BITREQ- /32BITPREF-