https://www.makeuseof.com/tag/3-ways-to-reset-the-forgotten-windows-administrator-password/
How many times have you forgotten a password in the last year? Losing a website password isn't a huge deal, because you can reset those with your email address. But forgetting your computer password is scary, because they're more difficult to reset.
If you've forgotten the password for a Windows administrator account, don't fear. There are several methods you can use to recover it. We'll show you how to reset administrator passwords in Windows, even if you don't have admin rights. While we focus on Windows 10 here, these tips should largely work the same in Windows 11 and other versions, too.
1. Reset the Windows Administrator Password With a Microsoft Account
One of the major benefits of using a Microsoft account with Windows is that you can reset your password by going through Microsoft's tools without much hassle.
First, make sure that you really can't access your Microsoft account (perhaps your keyboard has a stuck key or something similar). Go to login.live.com on your phone or another computer and try to sign in with the Microsoft account you use on your PC, making sure you don't mistype anything.
If you still can't get in here, then proceed with resetting your Microsoft password. Head to the Microsoft password reset page to get started, though you can also reset your password from the Windows login screen by clicking the I forgot my password link.

After confirming your identity with the details you've provided on your account, this page will walk you through resetting your Microsoft account password. Once that's done, use the new password to sign into your PC.
It's worth noting that if you have a Microsoft account, you should take a few minutes to update your security info on your Microsoft account page. Adding a phone number and secondary email address gives you options to reset your password easily; without them, it's much more of a hassle. A little bit of forethought now will make it much easier to reset your admin password in the future.
2. Reset a Local Windows Admin Password Using the Lock Screen Workaround
If you don't use a Microsoft account to log into Windows, you'll have to reset the password for a local account. Windows 10 and 11 allow you to set security questions for local accounts that help you get back in easily from the lock screen if you forget the password. If you haven't set those up already, however, they won't do you much good now.
If the locked account is the only administrator account on your PC, you'll need to first use a workaround to launch an elevated Command prompt. We walk through this process below.
However, if you have another administrator account on the computer aside from the one you're locked out of, you don't need to go through all these steps. In that case, log into the other admin account on your computer and change the password using the command line, which doesn't require jumping through as many hoops.
Setting Up the Password Reset Workaround
First, you'll need to create a bootable Windows 10 disk on a flash drive. This will obviously require another computer, since you can't get into yours.
Once you've made that, insert the drive into your PC so you can boot from the new installation. On most machines, you need to press F12 or a similar key as soon as you power on your computer to choose a device to boot from.
Boot from your flash drive, let the Windows installer load, and when you see the initial Windows Setup screen, press Shift + F10 to open a Command Prompt.

Next, you need to know which partition your Windows installation is on. Usually, this will be the C: drive, but it might be different for you. To check, type the following command, which will change the current directory of the Command Prompt to the root of the C: drive (or whichever letter you insert).
cd /d C:
If the command returns The system cannot find the drive specified, then that letter isn't right; try D and continue down the alphabet. Once you find the right drive, you'll want to change the directory again using the cd command. Type this line to access the System32 folder:
cd Windows\System32
If you see The system cannot find the path specified, you've selected a drive other than the one Windows is on. Change the drive to a different letter and try again until you find the right one.
Once you're in the System32 folder, you can pull a little trick. Windows includes an accessibility feature called Sticky Keys, which you can launch by hitting the Shift key five times quickly. By swapping the executable that runs Sticky Keys with a link to the Command Prompt's executable file, you can run a command line to reset your password right from the login screen.
To do this, type these two commands, one at a time. The first backs up the Sticky Keys shortcut in the C:\Windows folder (the .. is a shortcut to move to the parent folder) so you can restore it later; the second replaces the Sticky Keys shortcut with a Command Prompt shortcut. If asked to give approval for either, do so.
copy sethc.exe ..
copy cmd.exe sethc.exe

You're done here, so type this command to reboot the computer and head back to the normal sign-in screen:
wpeutil reboot
Running a Command Prompt to Change Your Password
In previous versions of Windows, you could simply run the renamed shortcut to access a Command Prompt right from the login screen. However, Microsoft Defender now blocks these attempts, so there's an extra step required. If you're on an old version of Windows 10, or still using Windows 8 or earlier, you can press Shift five times on the login screen to open a Command Prompt.
On modern versions of Windows 10 or Windows 11, you'll have to reboot into Safe Mode for this to work. To do this, click the Power menu in the bottom-right corner of the login screen. Then, hold the Shift key and click Restart. If you see a warning that restarting may cause people to lose work, click Restart Anyway.
Then, you'll see the advanced settings menu. Click Troubleshoot > Advanced Options > Startup Settings, then Restart. Your PC will reboot, then ask which startup option you want to use. Hit the 4 key to select Enable Safe Mode. This loads Windows with only the essential drivers and services, preventing Microsoft Defender from blocking the workaround.

When you reboot to the Windows sign-in screen in Safe Mode, hit Shift five times quickly. This should bring up a Command Prompt, which has administrator access. If this doesn't bring up the Command Prompt, repeat the steps in the above section, but use utilman.exe instead of sethc.exe as the file you rename.
Then, reboot into Safe Mode and click the Ease of Access icon at the bottom-right of the login screen, which should hopefully bring up the Command Prompt. On Windows 10, this icon looks like the clock icon in the bottom-right of the image below. On Windows 11, it looks like an outline of a person.