Simultaneous optimization of shape and flow parameters is performed for a combined free and forced convection flow through vertical rectangular channels with moving walls. The laminar flow is assumed to be fully developed in the axial direction. The wall velocity, the axial pressure gradient and the channel height in the transverse plane are taken as the optimization parameters. The sensitivity expressions of both the objective function and the flow rate constraint of optimization are obtained in terms of the relevant physical variables, as well as adjoint variables which satisfy additional p.d.e.'s. All equations are discretized using the finite element method. Numerical results are provided for the present constrained optimization problem for various values of the problem parameters which include the moving wall segment size and the Rayleigh number. The results indicate that with increased Rayleigh number the optimal values of the wall velocity and the axial pressure gradient are increased, while the optimal value of the channel height is decreased. General sensitivity expressions are also presented in the appendix which might be utilized for arbitrary boundary variations along with arbitrary optimization objectives in other investigations.