An ejecting device, wherein an ejector (14) is fitted to the tip part of a moving member (1) and shoulder parts (11, 12, 13) with different heights are provided at the tip part of the moving member, the moving member (1) is set in a moving device (3) and a detachable cap (2) is put on the moving member (1), a through hole (22) allowing the ejector (14) to pass therethrough and projected parts (21) projecting toward the center of the through hole (22) are formed at the tip part of the cap (2) and, when the moving member (1) is ejected by the moving device (3) and moved, either one of the shoulder parts (11, 12, 13) comes into contact with the projected part (21), whereby the projected length of the ejector (14) from the cap (2) can be restricted.