Toodarday
Toodarday

Reputation: 167

Batch - change account password with imput

I want to create a batch file when launched asks the user to change the current administrator password.

Step 1: User logins
Step 2: Batch file runs displaying message "Please change Administrator password"
Step 3: user types in new password
Step 4: sets new password for Administrator account
Step 5: deletes batch file

Step 5 must not happen unless the user changes password. I know how to set a task schedule for it to run just not sure what the code inside the .bat file needs to be.

Upvotes: 1

Views: 4405

Answers (1)

shadow2020
shadow2020

Reputation: 1351

@echo off
Set "password123="

echo "Please change Administrator password"
set /P password123=Enter your new password: 
If Not Defined password123 goto :exit
net user administrator %password123%
del "%~f0"

:exit
exit
  1. Echos "Please change Administrator password" as you requested
  2. Prompts for a password to change admin pass.
  3. Takes the user input and sets the pass.
  4. If no pass is typed, the batch file exits
  5. If a password is typed it deletes the bat file.

Upvotes: 2

Related Questions