A method is proposed to drive an ultrafast non-adiabatic dynamics of an ultracold gas trapped in a box potential. The resulting state is free from spurious excitations associated with the breakdown of adiabaticity, and preserves the quantum correlations of the initial state up to a scaling factor. The process relies on the existence of an adiabatic invariant and the inversion of the dynamical self-similar scaling law dictated by it. Its physical implementation generally requires the use of an auxiliary expulsive potential analogous to those used in soliton control. The method is extended to a broad family of many-body systems. As illustrative examples we consider the ultrafast expansion of a Tonks-Girardeau gas and of Bose-Einstein condensates in different dimensions, where the method exhibits an excellent robustness against different regimes of interactions and the features of an experimentally realizable box potential.