This isn’t a direct answer to your question, partly because we’d need a lot more details, and partly because I think there is probably a better solution, but it does address some of the issues and I hope it’s helpful, and there’s too much here to put in as comments.
There are lots of potential problems with what you’re proposing, and it’s likely to be a very inefficient and potentially risky way of achieving your objective. Operating systems aren’t really designed to be installed and uninstalled frequently.
You can download the windows installation media from Microsoft - you don’t need a license to download it; if it was installed on the computer before, the license is likely linked to the motherboard and so should activate.
If you haven’t done so already, it’s essential to back everything up - you should be able to access your windows files from Ubuntu to copy them to an external drive.
Long term, depending on what you were planning on using Ubuntu for, especially if it’s only for occasional specific purposes, you are likely to be much better off booting into a live usb session whenever you want to use Ubuntu, instead of installing the os and subsequently uninstalling it (select ‘try Ubuntu’ when you boot with the usb in, having changed the boot priority to usb first). You could alternatively create a persistent usb installation - again, that would leave Windows and your internal hdd untouched. There are lots of guides online, eg How to make a live Ubuntu 18.04 USB with a persistent storage of more than 4GB
Booting a live usb session from a usb pen drive takes slightly longer than booting from the internal drive … but dramatically less time than installing the os.
If for some reason you really do want a full installation, I think it is likely to be a much better solution to install Ubuntu in a relatively small partition - say 10 GB. It’s then using so little disk space that there really shouldn’t be any need to do repeated installations / uninstalls.