I can give you two solutions.
The first is to make a standard render for the texture, but with the file attached to it as a destination buffer. If your equipment is recent enough, this can be done in one go. This will cover all the necessary math in HW for you, but redistributing cubmap data is not ideal (quite a lot of distortion if angles). In most cases this should be enough.
After that, you render the square on the screen, and in the shader you map your UV coordinates to the xyz vectors using the staightforwad spherical mapping. HW will calculate for you which side of the cubic map to take at which UV.
, HW: . , 6 . , UV.