How To Change Password With Cmd

8 min read

Introduction

Changing a password using CMD (Command Prompt) is a quick and efficient method for IT administrators and power users who need to manage multiple user accounts without navigating through graphical interfaces. That said, this guide walks you through the entire process, from ensuring you have the right permissions to verifying that the new password is set correctly. By the end of this article you’ll know exactly how to change password with cmd on Windows 10, 11, or Server editions, using the built‑in net user command and optional scripting techniques. The steps are straightforward, but it’s important to understand the underlying mechanics so you can troubleshoot any issues that arise.

Prerequisites

Before you attempt to change a password via CMD, make sure you meet the following conditions:

  • Administrator privileges – The account you’re logged into must have local or domain admin rights. Non‑admin accounts cannot modify other users’ passwords.
  • Access to Command Prompt – Open CMD as an administrator (right‑click the Start button → Command Prompt (Admin)).
  • User account name – Know the exact username of the account you want to modify (case‑insensitive but spelling matters).
  • Network connectivity (optional) – For domain‑joined machines, a valid domain controller connection is required.

If any of these items are missing, the net user command will return an error such as “Access is denied” or “The specified account does not exist.”

Step‑by‑Step Guide

Below is a numbered list that details how to change password with cmd using the classic net user syntax. Each step includes the exact command you should type, the expected output, and tips for handling common scenarios.

1. Open Command Prompt with Elevated Rights

  1. Press Win + X, select Windows PowerShell (Admin) or Command Prompt (Admin).
  2. If the User Account Control (UAC) dialog appears, click Yes to grant administrative privileges.

Why? The net user command writes to the Security Accounts Manager (SAM) database, which is protected by Windows. Elevated rights bypass this protection.

2. Identify the Target User Account

  • For a local account, use the account name as it appears in net users (e.g., Administrator, JohnDoe).
  • For a domain account, prepend the domain name: DOMAIN\username or simply username if you’re already authenticated against that domain.

3. Choose Your Password‑Change Method

There are two common approaches:

  • Direct password assignment – Provide the new password directly in the command line.
  • Interactive prompt – Use the asterisk * to be prompted for the new password and confirmation without exposing it on screen.

3. Hospitals

Direct Assignment

net user username newpassword

Interactive Prompt

net user username *

The system will then ask you to enter and confirm the new password. This method is more secure because the password does not appear in the command history It's one of those things that adds up. Surprisingly effective..

4. Execute the Command

  • Direct Assignment Example
net user JohnDoe P@ssw0rd2024
  • Interactive Prompt Example
net user JaneSmith *

After pressing Enter, you’ll see a message such as “The command completed successfully.” If the password contains special characters, enclose the whole command in double quotes:

net user "User Name" "MyP@ss!2024"

5. Verify the Password Change

To confirm the change, you can attempt to log in with the new credentials (if you have physical access) or run the following check:

net user username

This displays the account’s properties, including the last password set date. Note that the actual password is never shown for security reasons And it works..

6. Optional: Enforce Password Policies

If your environment uses Group Policy, you may want to ensure the new password complies with complexity rules. You can enforce a temporary policy by running:

net accounts /minpwlen:8 /maxpwage:90 /minpwage:1 /uniquepw:5

These settings apply to all local accounts on the machine. For domain accounts, policies are usually managed through the Domain Controller’s Group Policy Management console.

7. Document the Change (Optional)

For audit purposes, you can log the action in a text file:

echo %date% %time% - Changed password for user %username% > C:\Temp\password_changes.log

Append the specific user and new password (if needed) to the same log file.

Scientific Explanation

The net user command is part of the Windows Server operating system’s Net.exe utility, which interacts directly with the Security Accounts Manager (SAM) on standalone workstations and with the Active Directory database on domain controllers. When you execute net user username newpassword, the following sequence occurs:

Counterintuitive, but true.

  1. Authentication Context – The command runs under the security context of the logged‑in user. If that user has administrative rights, the OS grants the necessary privileges to modify the SAM/AD object.
  2. Parameter Parsing – The command line parser extracts username and newpassword. For the interactive * method, the parser expects a password string from standard input.
  3. Password Hashing – Windows stores passwords as NTLM hashes (MD4 of the Unicode password). The net user command triggers the internal UserChangePassword API, which computes the new hash and writes it to the SAM registry key HKLM\SAM\Domains\Account\Users\Names\<username> (or the corresponding AD attribute unicodePwd).
  4. Audit Logging – By default, Windows logs password changes in the Security log under Event ID 4724 (User changed password) and 4725 (Account disabled). If auditing is enabled, administrators can review these logs for compliance.
  5. Policy Enforcement – If a Group Policy password policy is active, the new hash is validated against length, complexity, and expiration rules. If the password fails, the command aborts with “Password does not meet the current password policy requirements.”

Understanding these internals helps you diagnose why a command might fail (e.In real terms, g. , insufficient rights, account locked, or policy violation) and allows you to craft more dependable scripts using batch files or PowerShell’s NetUser cmdlet.

Frequently Asked Questions

Q1: Can I change a password for another user without knowing the current one?

A: Yes. The net user command does not require the existing password. Even so, you must have administrative privileges on the machine or domain. If the target account is a domain admin

Q1 (continued): Can I change a password for another user without knowing the current one?

A: Yes—net user does not prompt for the existing password. Still, the account you’re modifying must have a password change privilege granted to you. On a standalone workstation this means you need local Administrator rights. On a domain controller, you must be a member of the Domain Admins, Enterprise Admins, or a group that holds the “User Account Management” right (granted via the User Rights Assignment policy). If the target account is a domain admin, only another domain admin (or the Administrator account) can change its password; otherwise the operation will be denied with error “Access is denied.”


Q2: How do I automate password changes across multiple users with a batch script?

A: You can loop through a list of usernames and assign a temporary password, then force a password change on first logon. Below is a minimal example that writes a secure temporary password to a CSV file for later distribution:

@echo off
setlocal EnableDelayedExpansion

:: Path to the input file containing usernames (one per line)
set "input=C:\Temp\usernames.txt"
set "output=C:\Temp\password_resets.csv"
set "tempPass=TempPass!

:: Create/overwrite the CSV header
echo Username,TempPassword > "%output%"

:: Read each line from the input file
for /f "delims=" %%u in ('type "%input%"') do (
    net user "%%u" "%tempPass%" 2>nul
    if errorlevel 1 (
        echo Failed to reset password for %%u
    ) else (
        echo %%u,!tempPass! >> "%output%"
    )
)

echo Done. Temporary passwords written to %output%

Notes

  • The script runs under the current user’s security context, so see to it that account has sufficient rights.
  • For production use, consider encrypting the temporary passwords or delivering them via a secure channel (e.g., encrypted email, SMS, or a privileged vault).
  • After distributing the temporary password, you can enforce a password complexity and expiration policy by linking a Group Policy Object (GPO) that includes a Password Policy setting.

Q3: What happens if the account is locked out or the password never expires?

A:

  • Locked‑out accounts – net user will fail with error “The account is currently locked out and may not be unlocked by this device.” To reach, you must use net user username /active:yes after resetting the account’s lockout counter (e.g., by logging on locally or using Active Directory Administrative Center).

  • Password never expires – If the account’s “Password never expires” setting is enabled (found in the Account Options on the Advanced tab of the user’s properties in ADUC), net user will still accept a new password, but the expiration flag will remain cleared. This is useful for service accounts or built‑in administrator accounts that should never require a password change And that's really what it comes down to..


Q4: How can I verify that a password change was successful using PowerShell?

A: PowerShell’s NetAccount cmdlet (part of the ActiveDirectory module) can be used to check the PasswordNeverExpires and PasswordLastSet attributes. A simple verification script is:

Import-Module ActiveDirectory

$user = "DOMAIN\johndoe"
$newPass = ConvertTo-SecureString "MySecureP@ssw0rd" -AsPlainText -Force

# Change the password
Set-ADAccountPassword -Identity $user -NewPassword $newPass -PassThru

# Verify the change
$adUser = Get-ADUser -Identity $user -Properties PasswordLastSet, PasswordExpired
[array]$events = Get-EventLog -LogName Security -Source "User Management" -InstanceId 4724,4725 -After (Get-Date).AddMinutes(-10) | Where-Object {$_.Message -like "*$user*"}

if
Hot and New

Recently Completed

Fits Well With This

Explore a Little More

Thank you for reading about How To Change Password With Cmd. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home