A major goal of molecular electronics is the development and implementation of devices such as single-molecular switches. Here, measurements are presented that show the controlled in situ switching of diarylethene molecules from their nonconductive to conductive state in contact to gold nanoelectrodes via controlled light irradiation. Both the conductance and the quantum yield for switching of these molecules are within a range making the molecules suitable for actual devices. The conductance of the molecular junctions in the opened and closed states is characterized and the molecular level E 0, which dominates the current transport in the closed state, and its level broadening Γ are identified. The obtained results show a clear light-induced ring forming isomerization of the single-molecule junctions. Electron withdrawing side-groups lead to a reduction of conductance, but do not influence the efficiency of the switching mechanism. Quantum chemical calculations of the light-induced switching processes correlate these observations with the fundamentally different low-lying electronic states of the opened and closed forms and their comparably small modification by electron-withdrawing substituents. This full characterization of a molecular switch operated in a molecular junction is an important step toward the development of real molecular electronics devices.