A machine for disinfecting or sterilizing endoscopes comprises a tunnel having a first opening and a second opening, an upper wall delimiting the tunnel, first and second lateral walls respectively positionable at the first and second openings to obstruct the tunnel, a bath for receiving an endoscope, a bath support, a guide for guiding the bath support and the bath along the tunnel between a first endrun and a second endrun, in which the bath projects externally from the first tunnel opening and the second tunnel opening, respectively, to enable endoscope insertion and extraction. The upper wall forms, with the bath, a closed chamber for treating an endoscope when the bath is inside the tunnel. The first and second lateral walls are removably couplable to the frame to selectively obstruct the tunnel or enable the bath support and bath to reach the respective endruns.