Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


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

share|improve this question
up vote 19 down vote accepted

Add this line to the batch file:

share|improve this answer
NB: I believe that this will only work with LOCAL accounts, not DOMAIN accounts. But it appears that is what you need... – Glenn Sullivan Oct 4 '12 at 13:59

The option /expires is for account, not for password, check the command help.

From the documentation: "Causes the user account to expire if you specify the date."

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Scott Pack Oct 16 '12 at 2:29
The first sentence is IMPORTANT. Should be in accepted answer. – A.D. Feb 5 '15 at 3:04

The net user command can be used on local as well as domain accounts. Use the /domain switch for domain accounts.

For example, to see the information for domain user %1, use

net user %1 /domain

The full list of net user options is listed here:

share|improve this answer

Single AD user

For active directory users, you can use the dsmod command to change it for a single user:

dsmod user "CN=username,OU={User Org Unit},DC... etc" -pwdneverexpires yes

Multiple AD users

If you want to bulk set this property, you can do it for an entire organizational unit (OU) by using a the above in combination with dsquery.

First, to list all the users in a OU (this is safe to run, because it only outputs a list of users):

dsquery user "OU={your target OU},DC={your domain},DC={your domain extension}"

Then, assuming you are happy with the output of the above command, you can pipe it to dsmod like so:

dsquery user "OU={your target OU},DC={your domain},DC={your domain extension}" | dsmod user -pwdneverexpires yes

Some more info, with screenshots, here:

share|improve this answer

As stated above, net user does not appear to allow the otpion to change password expiry only account expiration (through /expires).

This is what I used to remove the password expiration for my account:

wmic UserAccount where Name='username' set PasswordExpires=False

Change 'username' to the username of the account you wish to change.

share|improve this answer
This is already the accepted answer from four years ago. – Sven yesterday

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.