In addition, your situation and fix is another great example of why creating system images is so important. There are other methods of backup, but a system image is just about the only one that can get you out of the worst jams, including having your HDD or SSD go kaput. Replacing a drive and restoring the image is so much easier than having to install everything all over again. Personally, I keep three images for each computer, one for the current month and one each for the previous two months.
Ryzen 5 3400G | MSI B450M Pro-M2 MAX | 16GB Corsair Vengeance DDR4 3000 | XPG SX8200 Pro 512GB NVMe | Windows 10 Pro