Crop cultivation in solar greenhouses is affected by issues such as low levels of automation in spraying machinery, inefficient spraying, and a lack of suitable spraying equipment for vertically cultivated crops, all of which are in urgent need of resolution. To address these problems, this paper proposes a suspended-rail automatic variable-distance targeted spray system. The rated working speed of the spray system is 0.3 m/s, and the rated working pressure is 0.3 MPa. This system achieves precise spraying of crops at varying heights by dynamically adjusting the position of the spray nozzle. To ensure accuracy in spraying, the system employs a laser ranging sensor for real-time measurement of crop positions and spraying distances. Combined with a parameter processing scheme, the system generates control signals to adjust the operation of the electric push rod and electromagnetic valve, thereby dynamically adjusting the spraying distance and timing. Using vertically cultivated potted peppers as experimental subjects, this study compares the performance of fixed- and variable-distance spraying modes. The results indicate that, compared to the fixed-distance mode, the automatic variable-distance mode increases pesticide adherence by 16.65% and reduces pesticide usage by 29.58%. The proposed suspended-rail automatic variable-distance targeted spray system offers an effective technical solution for the precise spraying of vertically cultivated crops in solar greenhouses and thus contributes to improved pesticide utilization efficiency, reduced pesticide residue, and lower environmental pollution.