The question says it all - from my experience watching the shows, but not reading any books or other media, all "captains" are captains of ships. Is it possible for a starfleet officer to be promoted to captain and then admiral without being in command of a ship or base?
Montgomery Scott achieved the rank of Captain without serving as a ship's captain. He was referred to as a Captain of Engineering while serving on the Excelsior as chief engineer while holding the rank of Captain.
Likewise, McCoy became an admiral by the time of TNG without any indication of command experience.
Philippa Louvois, the Judge Advocate who presided over Data's trial on whether or not he is property held the rank of captain.
There should likely be MORE Captains in specialties (medical, legal, engineering, various sciences, Logistics, etc) than those who command a starship just like their are plenty of Colonels who never were commanders in the Army for example.