Disconnecting or discharging the battery is exactly what causes this condition. My battery is pulled with each winter storage and I need to restablish the limit positions every spring as described below.
From the factory repair manual:
Effect of disconnection or total discharge of the battery on electrical systems in the vehicle, subsequent measures:
64 52 Power windows:
Problem :
The limit positions of the power windows are deleted from the control module
when the battery is disconnected and connected.
Remedy:
Manually close each power window as far as it will go, then press the rocker
switch for closing the window again. The limit position of the respective window is
now stored in the control module again.
Now, you would do this with the top in the UP position to set that window height as the limit position to be stored.