Section 26. The selectmen shall forthwith give written notice in detail to the owner, constructor or person using any line constructed or maintained in violation of such regulations; and if thereafter such unlawful construction is continued or if said lines are not within a reasonable time so altered as to conform to said regulations, the supreme judicial or superior court may enjoin the further progress of said work, or order such line removed or altered at the expense of the owners, constructors or persons using the same. If such line belongs to or is used by a town, like action may be taken upon complaint of a person injured, after such notice to the town as the court may order.