Sliding ferroelectricity is a unique type of polarity recently observed in van der Waals bilayers with a suitable stacking. However, electric-field control of sliding ferroelectricity is hard and could induce large coercive electric fields and serious leakage currents that corrode the ferroelectricity and electronic properties, which are essential for modern two-dimensional electronics and optoelectronics. Here, we proposed laser-pulse deterministic control of sliding polarization in bilayer hexagonal boron nitride by first principles and molecular dynamics simulation with machine-learned force fields. The laser pulses excite shear modes that exhibit certain directional movements of lateral sliding between bilayers. The vibration of excited modes under laser pulses is predicted to overcome the energy barrier and achieve the switching of sliding polarization. Furthermore, it is found that three possible sliding transitions-between AB (BA) and BA (AB) stacking-can lead to the occurrence of dynamical magnetic fields along three different directions. Remarkably, the magnetic fields are generated by the simple linear motion of nonmagnetic species, without any need for more exotic (circular, spiral) pathways. Such predictions of deterministic control of sliding polarization and multistates of dynamical magnetic field thus expand the potential applications of sliding ferroelectricity in memory and electronic devices.