Pupils come through the trees on the left of the train in the picture
Children damaging property are endangering lives by using an unofficial short-cut over a railway line, according to a railway company.
The Welsh Highland Heritage Railway called recent damage to a new fence at Porthmadog in Gwynedd within within 24 hours of construction the "last straw"
Railway chairman James Hewett said something had to be done.
Ysgol Eifionydd secondary school said pupils had been spoken to and warned against trespassing on the rail line.
"This has been going on for years, basically it is an unofficial footpath, or short-cut from the school into the town of Porthmadog," said Mr Hewett.
"The children are not allowed out of the school during their lunch break without permission and some of them get round that by taking this path," he added.
In addition to the damage to the fence, some of the children were verbally abusing, swearing and spitting at railway volunteers, Mr Hewett said.
"The last straw was the fence being damaged yet again.
"If they get run over it won't do anyone any good," he said.
The railway company depends on volunteers to run it and Mr Hewett said some of them were fed-up with the treatment they received from some of the pupils.
"For the moment I'd like to see patrols on the school grounds at lunchtime to stop the children getting onto the line.
"Then long term we are talking of erecting security fencing which is expensive at £10-15 a metre, and we are talking a lot of it.
"We had put up a chain link fence with barbed wire on top, but they have tools and cut it with wire cutters."
Despite the difficulties Mr Hewett said he was anxious to have good relations with the school.
"We are all part of the community, and in fact one of the pupils comes here to work with us during his holidays.
"It's not all the pupils, just some. It is a big school, but at the end of the day it is a health and safety issue," he added.
Ysgol Eifionydd head teacher Richard Williams confirmed the school had received complaints from the railway company.
"We have reminded pupils that they should not leave school grounds during school hours without permission, and that they should not trespass on the Highland Railway's property," he added.