You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何无需登录目标用户且无需旧密码,通过命令/VBS/BAT修改账户密码

How to Modify a Windows User Password Without Logging In or Entering the Old Password

Got it, let's break this down. First and foremost: you must have administrative privileges to pull this off—Windows restricts password changes for non-admins for obvious security reasons. Below are proven solutions that let you modify a user's password without logging into their account or entering their old password:

1. Command Line (CMD/PowerShell)

CMD with net user

This is the simplest built-in command. Open CMD as an administrator, then run:

net user <TargetUsername> <NewPassword>

Example: To set the password for user "JaneDoe" to SecurePass123!:

net user JaneDoe SecurePass123!

If your new password includes spaces or special characters like &, $, wrap it in double quotes:

net user JaneDoe "Secure Pass!123$"

PowerShell with Set-LocalUser

For a slightly more secure approach (avoids plaintext password in some contexts), use PowerShell as admin:

# Option 1: Direct plaintext input (note: may appear in command history)
Set-LocalUser -Name "JaneDoe" -Password (ConvertTo-SecureString "SecurePass123!" -AsPlainText -Force)

# Option 2: Prompt for password (no plaintext in history)
$newPassword = Read-Host "Enter new password for JaneDoe" -AsSecureString
Set-LocalUser -Name "JaneDoe" -Password $newPassword

2. Batch Script (BAT)

Create a reusable batch file to automate the process. Save this as ChangePassword.bat:

@echo off
:: Replace these values with your target user and new password
set "TARGET_USER=JaneDoe"
set "NEW_PASSWORD=SecurePass123!"

:: Run the net user command
net user %TARGET_USER% "%NEW_PASSWORD%"

:: Confirm success
if %errorlevel% equ 0 (
    echo Success! Password for %TARGET_USER% has been updated.
) else (
    echo Failed to update password. Check admin rights and password policy.
)
pause

Important: Right-click the batch file and select Run as administrator to execute it.

3. VBScript

If you prefer VBS, use this script to modify the password via WMI. Save as ChangePassword.vbs:

strTargetUser = "JaneDoe"
strNewPassword = "SecurePass123!"

' Connect to the local user account
Set objUser = GetObject("WinNT://./" & strTargetUser & ",user")

' Set and save the new password
objUser.SetPassword strNewPassword
objUser.SetInfo

WScript.Echo "Password for " & strTargetUser & " has been changed successfully."

Run it by right-clicking and selecting Run as administrator, or execute via admin CMD:

cscript ChangePassword.vbs

Key Notes

  • Local vs. Domain Accounts: These methods work for local user accounts. For domain accounts, you need domain admin rights. Use net user <Username> <NewPassword> /domain in CMD, or PowerShell's Set-ADUser (requires RSAT Active Directory tools installed).
  • Password Policy: Ensure your new password meets the system's password requirements (length, complexity, age) — otherwise the command/script will fail.
  • Security Best Practices: Avoid hardcoding plaintext passwords in scripts if possible. Use the PowerShell prompt method or secure input alternatives to prevent password exposure in command history or script files.

内容的提问来源于stack exchange,提问作者qwqw

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:27:46