Windows – How to Create a Never Expiring Password & User via .bat File

batchwindows

I am using a .bat file to create a user and password at windows operating system level.

The issue am facing is when i pass EXPIRES:NEVER for password, when the user is created, it doesn't have "Password never expires" checkbox checked (meaning the password never expires is selected for that created user) and the user expires automatically after 90 days.

Net User %1 %2 /COMMENT:"%3" /EXPIRES:NEVER /PASSWORDCHG:NO /ADD

The above is the main line of code, i pass user name and password from a text file and run the .bat file.

Best Answer

Add this line to the batch file:

WMIC USERACCOUNT WHERE "Name='%1'" SET PasswordExpires=FALSE