Such railroad companies with the consent of the comptroller may provide, construct and install, maintain, change, and repair such means for the transmission and return of electric, compressed air, or other motive power for such motive purposes along, upon, and over such highways, streets, or roads upon which they have rights of way by franchise as may from time to time be necessary for the operation of the railroads; provided that the railroad companies shall so exercise this right that unnecessary injury or deterioration shall not occur nor be done to the water pipes, sewer pipes, gas pipes, or other property of the State, or of any person and shall save the State, or any person harmless and indemnified from all loss, cost, damage, and expense by reason thereof.