Consequently, between 1784 and 1789 the castle was yet again rebuilt, this time by Stanisław Zawadzki, who converted it into military barracks. The outbuildings were enlarged substantially. Since that time the building housed the Lithuanian Foot Guard Regiment and the 10th Foot Regiment. During the Kościuszko's Uprising the castle was the main centre of conscription for the 20th Foot Regiment. After the Partitions of Poland, during the Prussian occupation of Warsaw, the building was abandoned. After the proclamation of the Duchy of Warsaw it was again restored to the army and was converted into a military hospital. However, the plans of converting it to the Central Military Hospital of the Polish Army were postponed by the Congress of Vienna which awarded the Congress Poland to Russia. On April 1, 1818 the hospital was officially opened. It had places for up to 1000 wounded soldiers. After the outbreak of the November Uprising the hospital was enlarged to 1250 beds and an additional annex with places for 600 was opened in the nearby Łazienki complex.