The conventional approach to the theoretical study of chemical reactions has been to study the reactivity of atoms and molecules in isolation. However, practical chemistry takes place in solution, at surfaces and in general under conditions of strong interaction with the surrounding environment. Furthermore, thermodynamic parameters strongly influence the way and the speed at which a reaction proceeds. Ab-initio molecular dynamics offers a unique tool for studying and understanding chemical processes as they normally take place in the laboratory or in industry. In fact, it combines chemical accuracy with the possibility of studying the influence of the environment and the effect of temperature and pressure. One limiting factor, however, is the time scale over which most chemical reactions take place, which far exceeds the simulation time scale. We shall present a method that is able to generate classical trajectories with fixed initial and final boundary conditions. Our method is based on the minimization of a suitably defined action. In combination with the path sampling method of Chandler et al., it promises to be a powerful tool for solving the time scale problem in the study of chemical reactions and in other systems.