You can reinstall Windows from scratch using the product key that came with your PC, but you’ll have to find installation media yourself. Microsoft offers free ISO files for downloading; you just have to know where to look.

There area few ways to do this, but they’re all on the straight and narrow–you won’t have to visit a shady BitTorrent site to download ISOs that may be filled with malware. Instead, you get official installation media straight from Microsoft.

NOTE: depending on the OEM version of Windows that you are running, you might run into an issue using the OEM key with a retail version of Windows. If it won’t activate, you can always install and then call Microsoft to get them to straighten it out and allow your copy to activate. The most important thing is that you have a valid license key.

Download the Windows 10 or 8.1 ISO Using the Media Creation Tool

If you’ve got access to a Windows machine, the official method for downloading ISOs for Windows 8.1 and 10 is the Media Creation Tool. The process for using the tool is largely the same for both versions of Windows, so we’ll be using the Windows 10 Media Creation Tool for our example. We’ll just note where anything differs.

One caveat you should be aware of up front is that you can no longer download an ISO for Windows 8–just 8.1. And the product keys are different for Windows 8 and 8.1, so if you have a Windows 8 product key, you can’t just use it to install Windows 8.1. Instead, you’ll have to install Windows 8, then do a free upgrade to 8.1. After you do the upgrade, Windows will assign the new product key to the installation. You can find that product key in a number of different ways and save it for the future. After that, you should be able to do a clean installation of Windows 8.1 using the new product key and won’t have to worry about installing Windows 8 first and going the upgrade route.

Start by downloading either the Windows 10 Media Creation Tool or the Windows 8.1 Media Creation Tool. Once the file has downloaded, just double-click it to start the tool and then click “Yes” to give it permission to make changes to your PC. When the tool starts, click “Accept” to accept the license terms. Note that the Windows 8.1 version of the tool does not ask you to accept license terms.

When the tool asks what you want to do, select “Create installation media for another PC” and then click “Next.” The Windows 8.1 version of the tool also does not provide this option; it just defaults to creating installation media for another PC (which is what we want).

The tool will suggest a language, edition, and architecture for Windows based on information about the PC on which the tool is running. If you’re going to use the installation media on that PC, go ahead and just click “Next.” If you’re planning to install it on a different PC, clear the “Use recommended options for this PC” check box, select options that are more appropriate for the license you have, and then click “Next.” Note that if you’re using the 8.1 version of the tool, you actually start with this screen. The tool also won’t recommend options; you have to select them yourself.

Remember, your license will only work with the correct version of Windows–if your license is for 64-bit Windows 10 Pro, you can’t install 32-bit Windows 10 Home with it, so ensure your selections here match what’s listed on your product key.

Next, select whether you want the tool to create a bootable USB flash drive with the installation media, or just create an ISO file that you can use or burn to a DVD later. We’re going with the ISO file in this example, but the process is much the same either way. If you go with the USB option, you’ll need to provide a USB drive with at least 3 GB of space. Also, the USB drive will be formatted during the process, so make sure there’s nothing on it you need. Select the option you want and then click “Next.”

Choose a place to save the finished ISO file (or point the tool toward the right USB drive if that’s the option you chose).

At this point, the Media Creation Tool will begin downloading the files and assembling your ISO, which can take a fair bit of time depending on your internet connection. When it’s finished, you can click “Open DVD Burner” if you want to go ahead and create a disc or just click Finish if you don’t want to make a disc right now.

Download the Windows 7 SP1 ISO Directly From Microsoft’s Website

Microsoft makes the Windows 7 SP1 ISO available for direct download through their site. The only catch is that you’ll need a valid product key in order to download the file–and OEM keys (like the one that came on a sticker under your laptop) won’t work. If that’s you, proceed to the next section.

If you do have a valid retail key, head to the Windows 7 download page, enter your product key, and click “Verify” to start the download process.

After your product key is verified, select the product language you want to download and then click “Confirm.”

Next, choose whether you want the 32-bit or 64-bit version of Windows 7. When you click whichever version you want, the download will begin. Note that download links generated by the site are only valid for 24 hours. Of course, you could always come back and walk through the verification and selection process again to generate new links.

After downloading the ISO file, you can burn it to a DVD by right-clicking it in Windows Explorer and selecting “Burn disc image” to burn it to a disc. If you want to install Windows 7 from a USB drive, the best way is to use the Windows 7 USB/DVD Download Tool to put that ISO file onto a USB drive.

The downloaded ISO you’ll get from Microsoft includes Windows 7 with Service Pack 1. When you install Windows 7, you can avoid the hassle of downloading and installing the hundreds of updates that came out after SP1 by installing the Windows 7 SP1 Convenience Rollup. Even better, why not take a little extra time and slipstream the Convenience Rollup right into your Windows 7 ISO? That way, whenever you install Windows 7 in the future, you’ll have one ISO with all the updates (at least up through May 2016) already included.

Download Any Windows or Office ISO Using a Free Third-Party Tool

Microsoft used to make all these ISOs available through a site called Digital River, but it doesn’t anymore. Instead, they’re stored on its TechBench site. The ISOs can be hard to find, though, and for versions of Windows other than the most current, the site tries really hard to push you into using the Media Creation Tool instead. Enter the Microsoft Windows and Office ISO Download Tool. This free utility provides a simple interface that lets you select the version of Windows you want, then downloads an ISO for that version straight from Microsoft’s download servers. This includes various builds of the Windows 10 Insider Preview. You can also use the tool to download ISOs for certain versions of Microsoft Office.

First, head over to HeiDoc.net and grab the Microsoft Windows and Office ISO Download Tool. It’s free and it’s a portable tool, so there’s no installation. Just launch the executable file. In the main window, choose the version of Windows or Office you’d like to download.

Click the “Select Edition” drop-down menu and then choose the edition you want. Note that in addition to the regular editions of the product (such as Home or Professional), you can also download regions specific editions such as Windows N (which is sold to the European market and does not include multimedia apps like Media Player and DVD Maker) and Windows K (which is sold to the Korean market).

After you select the edition you want to download, click “Confirm.”

Next, use the drop-down menu that appears to choose the product language you want to download and then click the “Confirm” button under the language drop-down menu.

Finally, choose whether to download the 32-bit or 64-bit version of the product. Clicking either download button will initiate the download using the ISO download tool, so you’ll need to keep it open until the download finishes. Alternatively, you can use the “Copy Link” buttons to the right to copy the direct download link to your clipboard and then download the file using your browser. Either way, note that most links generated by the tool are only valid for 24 hours, though you can always come back and generate new links.

And that’s all there is to using the Microsoft Windows and Office ISO Download Tool. Yes, you could accomplish some of this by digging around the TechBench site, but using this clever little utility is quicker and saves a lot of hassle. Plus, for some products, like Windows 8.1, finding the direct download on the site is next to impossible.

Microsoft also provides other software via the TechNet Evaluation Center. For example, you could download a trial version of Windows Server 2012 R2 and enter a legitimate product key to get the full version. Just click the “Evaluate Now” header on the site to see what trial versions of software are on offer. You will need to sign in with a Microsoft account before downloading.