I find it strange that people would suggest that Barclay is mentally ill...
Don't people understand where his root problem lies? It's simple really, he's SHY.
All his problems stem from shyness and introversion.
Since when was that a mental illness?
As for reaching high ranks without commanding, people obviously don't understand the way the military works.
I'm a former Navy person and the people that command the big warships are the executive branch types.
If barclay was to command a ship it would probably be some kind of science vessel.
I'd imagine that a medical ship would probably be commanded by some kind of high ranking doctor.
Apart from that though, it is completely possible in things like the navy to reach high ranks without ever serving on a ship. In fact, the higher concentration of those higher ranks is actually among people that never see service on a ship.
You should see serving on a ship as being something that is just one way that people can go. Don't forget that there are tons and tons of starfleet bases all over the place. There are probably actually a much greater amount of manpower in bases than could ever be accommodated on the fleet of ships.
And then there are hospitals. And then there are scientific outposts. Probably plenty more besides.