Using Command Prompt to reset your Windows password

You can reset a forgotten Windows password through Command Prompt, but the method depends on whether you can still log in to your computer at all. If you can reach the Windows login screen but cannot remember your password, you will need to restart into Safe Mode or use the built-in Administrator account. If you are already logged in as a different user, you can reset another account's password directly from Command Prompt without restarting.

The most common scenario — you are locked out entirely — requires you to boot into Safe Mode with Command Prompt, then use the net user command to create a new password. This works on Windows 10 and Windows 11 for local accounts, though the exact steps vary slightly between versions.

Key Takeaways

  • If you are locked out, restart your computer and press F8 or Shift+F8 repeatedly during startup to reach the Advanced Boot Options menu, then select Safe Mode with Command Prompt.
  • Once in Command Prompt, type net user [username] [newpassword] to reset the password for any local account on the machine.
  • If you do not remember the exact username, type net user alone to see a list of all accounts on the computer.
  • This method works only for local accounts; if your computer is connected to a domain or uses a Microsoft account, you will need to use the password reset link sent to your recovery email instead.

Restarting into Safe Mode with Command Prompt on Windows 10

Start by shutting down your computer completely. Turn it back on and watch the screen carefully. As soon as you see the Windows logo or the manufacturer's splash screen, begin pressing the F8 key repeatedly — press it every half-second or so until a menu appears. On some machines, you may need to press Shift+F8 instead, or hold Shift while clicking Restart from the login screen.

When the Advanced Boot Options menu appears, look for an option labeled "Safe Mode with Command Prompt" and select it using the arrow keys, then press Enter. Your computer will restart again and load into a black screen with white text — this is Command Prompt running in Safe Mode. You should see a prompt that looks like C:\Windows\system32> with a blinking cursor.

Restarting into Safe Mode with Command Prompt on Windows 11

Windows 11 removed the F8 boot menu, so the process is different. From the login screen, hold the Shift key and click the Power button in the bottom right corner. Select Restart while still holding Shift. Your computer will restart into the Windows Recovery Environment.

Once there, click Troubleshoot, then Advanced Options, then Command Prompt. Windows will restart again and load Command Prompt in Safe Mode. You will see the same black screen with the system prompt ready for commands.

Entering the password reset command

At the Command Prompt, type the following command exactly as shown, replacing [username] with the account name you need to reset and [newpassword] with the password you want to set:

net user [username] [newpassword]

For example, if your account is named "Sarah" and you want to set the password to "BlueSky2024", you would type: net user Sarah BlueSky2024 and then press Enter. The system will respond with "The command completed successfully" if it worked. Do not include the brackets — they are just placeholders to show you where to put your information.

If you do not remember the exact spelling or capitalization of your username, type net user by itself and press Enter. The system will display a list of all local accounts on the computer. Find the one you need to reset, note the exact name, and then run the command again with the correct username.

What to do if you do not know your username

If you cannot remember which account name belongs to you, the net user command will show you all accounts. Look for the one that is not "Administrator" or "Guest" — that is usually your personal account. If there are multiple personal accounts and you are not sure which is yours, you can try resetting each one until you find the right account.

Once you have reset the password, type exit and press Enter to close Command Prompt. Your computer will return to the login screen. Log in with your username and the new password you just created. After you are back in Windows, you can change the password to something you prefer by opening Settings, going to Accounts, and selecting Change Your Password.

When this method will not work

This Command Prompt method works only for local accounts — accounts that exist only on your computer. If your Windows login uses a Microsoft account (the kind you sign in with an email address), you cannot reset the password through Command Prompt. Instead, you will need to use the password reset link at account.microsoft.com, which sends a code to your recovery email or phone number.

If your computer is part of a workplace domain or connected to Active Directory, Command Prompt will not let you change the password either. In that case, contact your IT department or help desk — they have tools to reset domain account passwords. Attempting to reset a domain account through Command Prompt will produce an error message saying the request is not supported.

Resetting another user's password while already logged in

If you are already logged into Windows as a different user — for example, you are logged in as Administrator and need to reset a family member's account — you do not need to restart into Safe Mode. Open Command Prompt normally by typing "cmd" in the Windows search box, right-click on Command Prompt, and select Run as Administrator.

Then type the same net user [username] [newpassword] command. Because you are running as Administrator, the system will allow you to reset any local account on the machine. This is much faster than restarting, and it is the method to use if you have access to any Administrator account on the computer.

Frequently Asked Questions

What if the command says "The system cannot find the file specified"?

This usually means you are not actually in Safe Mode with Command Prompt — you may be in regular Safe Mode instead. Restart the computer and try the boot menu again, making sure you select the option that specifically says "Command Prompt" rather than just "Safe Mode". On Windows 11, double-check that you selected Command Prompt from the Advanced Options menu.

Can I use a password with spaces in it?

Yes, but you must put the entire password in quotation marks. For example: net user Sarah "Blue Sky 2024". Without the quotes, the system will only use the first word as the password.

What if I get an error saying "Access denied"?

This means you are not running with Administrator privileges. If you are already logged in, make sure you right-clicked Command Prompt and selected Run as Administrator. If you are in Safe Mode, restart and try again, confirming you are in Safe Mode with Command Prompt, not regular Safe Mode.

Will resetting the password this way delete my files?

No. Resetting the password through Command Prompt only changes your login credentials — it does not affect any files, programs, or data on your computer. Everything will be exactly as you left it once you log back in.

Can I reset a Microsoft account password this way?

No. Microsoft accounts must be reset through the online password recovery page at account.microsoft.com. If you try the Command Prompt method on a Microsoft account, you will get an error. Go to the Microsoft account recovery page and follow the prompts to reset your password using your recovery email or phone number.