We report a method of optical excitation of nanomechanical cantilever-type oscillators. The periodic driving signal with a controlled modulation amplitude was provided by a 415 nm diode laser, wherein the laser spot was located at some distance away from the clamped end of the cantilever. The measured resonant response of the cantilever was obtained at distances in excess of 160 μm with varying oscillator dimensions. The effectiveness of the driving mode is studied for different combinations of materials, namely Si- SiO2 and Si3N4-SiO2. These observations were considered within the theoretical framework of the mechanism of heat transfer. We show that measurable amplitudes of vibrations can be obtained at temperature changes much less than 1°.