The 4th Amendment protects against unreasonable searches and seizures. Normally, an officer could not enter and search a car that is legally parked without a warrant. However, there are some exceptions to the warrant requirement. For example, if he could see illegal items inside the car through the windows, that might justify a warrantless search. Also, the rule of "exigent circumstances" often will validate a search without warrant. For example, noticing that the car was unlocked, he might have entered it to secure it for the protection of the owner.
If there is an illegal search, and the police discover evidence they wish to use against you in a criminal trial, you can file a motion and ask the judge to suppress that evidence from being used in court. That is not the same as the officer getting into trouble. The 4th Amendment does not contain any remedy of punishment for the officer. If the officer in good faith believes he is authorized to search then he would not get in legal trouble for searching.
If you are charged, have your attorney file a motion to suppress, a motion which might or might not win. If you are not charged, you should not expect officials to prosecute the officer, though it is not completely impossible they could charge the officer with a misdemeanor like trespassing or entering a car without permission. Only the prosecutor can decide to prosecute someone; an individual does not have that right. An individual can sue for damages, if there are any.
If you do not want people going into your car, you might consider locking it. Also, by parking on school property a court might find that you waived your rights against search, so you might consider a different place to park. You also might consider not leaving embarrassing items in your car that you do not want to be discovered.
Contact me at 248-399-6930 for a free consultation. You and I do not have an attorney-client relationship formed by our communications on this website. Advice given by me on this website is general advice based on partial information. You should not rely on any advice given without first hiring a lawyer in the area where the case is pending, and providing that lawyer with full information.
I do not think that the answer can be given without further information.
Courts that have allowed searches of cars on school premises haven't equated them with searches of school lockers. There is a reason for this. The school retains ownership and control of the locker and a student's use of it is by the permission of the school. The school's relationship to your car is not the same.
If we are talking about a car owned by a student (or the student's parents), the basis for a search still has to be upon probable cause.
Cases allowing warrantless searches to be sustained have evidenced that probable cause. For example, a locker run using drug sniffing dogs alerts on a locker. The police then use the dog to run the parking lot. The dog then alerts on a car (or cars). The dog's alerting on the car, in courts sustaining such searches subsequent to the dog search, gives rise to probable cause to believe that there are illegal drugs in the car. That probable cause gives rise to the basis on which sustaining courts have upheld such searches. A better practice would still be to obtain a warrant based on the dog's alert to the car.
To my knowledge the Supreme Court has not ruled definitively on this question.
If you were not a student, other issues arise.
If the officer simply went from car to car on the basis of no reasonable suspicion and no probable cause then cases that have sustained searches after probable cause came into existence because of a drug dog's alerting are not controlling, perhaps not even relevant.
The employment of the "school cop" also affects the analysis of your question. If this "school cop" is NOT a law enforcement officer, is acting at the behest and direction of the school, the standard to which the school must attain is, essentially, a lower one than if the "school cop" is a law enforcement officer. The nature of the employment of the officer varies by jurisdiction.
In my view, if the latter was the case, a car to car fishing expedition by a law enforcement officer assigned to the school (rather than a school security employee) with nothing better to do, makes the question of exactly what damages or losses you suffered irrelevant. The loss you suffered at that point is the one to integrity of your property rights, which are violated by warrantless searches absent probable cause.
Of course, the fact that you may have suffered a violation of your rights in that case does not mean litigation is a sensible act. In the first instance, if this is what happened consulting with an attorney seems to me to be the best course.
This answer is not a substitute for consulting with and retaining the services of an attorney for your legal needs. By providing this answer, I am not entering into an attorney client relationship with you.