Answer
Neither of the conflicts Joseph I was involved in were resolved until the Treaty of Utrecht, which was signed in 1713 and ended the War of the Spanish Succession. The treaty ceded the Spanish throne to Philip V, the grandson of Louis XIV of France, and recognized the Austrian Habsburgs as the rulers of the Holy Roman Empire.