The oddball accident occurred on Thursday around 7.30am after the 60-year-old bus driver stepped out of the articulated vehicle to open a door that had been blocked by several students, cantonal police said.
The articulated bus, at a bus stop on a road sloping downhill, moved 20 metres and ploughed into the side of the barn, becoming embedded in the wood building, police said.
The reason why the bus moved is still being investigated.
Around 30 of the students were treated at the site of the accident by paramedics, while ambulances took 12 more suffering from minor injuries and shock to local hospitals, police said.
The school bus was transporting the children, aged 13 to 15,from the surrounding region to a school in Farvagny, a town in the centre of the canton, midway between the cities of Fribourg and Bulle.
Students unharmed by the incident were taken in a second bus to the school, which was aided by the canton’s psychological support centre, police said.
It took about five hours for experts to extricate the bus from the barn, which was cordoned off for security reasons.
Because of the damage caused a person renting lodgings in the building had to be rehoused, police said.
No damage estimate was immediately available.
An investigation is continuing into the crash.