Not really possible without DLL. The closest I was able to come was with a turret class building tapped inside another building which prevented it from being able to shoot anything down low. The problem was that it would still target ground units and just sit there pointing even while aircraft flew overhead. Even the ODF command gunTowerProcessCheckCantHit = true didn't make it retarget aircraft when this happened, even though it says in the changelog that it is supposed to retarget if it can't hit a unit.
attackTask = "ArtlAttack"
subAttackTask = "ArtlSubAttack"
Might make it more inclined to fire upwards, been a while since I played with it though so I'm not sure. I don't think you can stop it firing at ground units completely.
And, terrain shaping doesn't work on buildable gun towers, heh...
EDIT: Figured out one bit...
MinWeaponPitch = -0.2
MaxWeaponPitch = 1.5
min is set to - in code, so to make minimum pitch a positive number, it needs to be negative.
Now they physically can't aim down, or level. However, the AI still "tries" to aim at ground targets it can't hit, even with GunTowerProcessCheckCantHit = true
what I did to create an aa only emplacement was to actually have the tower launch a satellite up 200m and gave it a weapon with 200 m range so it basically could only target object in the air, looks pretty damn cool too haha. I dont remember if it was 200m range and altitude, but that was the general idea. I think i may have gave it a lil more weapon range then height so it would attack ground targets very close to it's base structure.
You could probably get a similar effect with a ground based tower as long as the control points were up high, since target selection for the ai was based on certain hardpoints, which i cant recall the specific names for, while still having the weapon hardpoints on the ground, but i don't think i ever messed with that, worth a try though if you want a certain look.
I think com messes with what is drawn on the screen, i had some issues with that and the satellite i think, things may have changed though. if the com hp was off the screen the model wasn't shown, so placement of that required a lot of fine tuning...
Fake Z axis means 200 meters is not measured vertically. If something is 300 meters in the air, but 1 meter away from it x or y, that ship will point up and attempt to attack as if it was right next to it.