In 1805, he received the command of a corps, with which he did good service at Ulm. He was then directed to take possession of Dalmatia with his army and occupied the Republic of Ragusa. For the next five years, he was military and civil governor of Dalmatia, and traces of his beneficent régime still survive both in great public works and in the memories of the people. In 1808, he was made duke of Ragusa.