Script to disable password expiry for local Windows accounts

This content is 20 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

One of the shortcomings of the net user command in Windows is the inability to set the password never expires flag on an account (account expiry options can be set, but not password expiry and the full syntax is described in Microsoft knowledge base article 251394).

There are 13 flags on an NT SAM/Active Directory user account which may be manipulated using VBScript (for further details of the 13 flags, see Microsoft’s sample scripts or there is some useful information about the object model at the Motobit Software website).

This script can be used to set the password never expires flag on a specified account. I’ve tested it against the local SAM database on a Windows XP PC, but in theory it should work on all versions of Windows NT (2000, XP, 2003 Server, etc.) and also against Active Directory accounts if you run it on a domain controller.

11 thoughts on “Script to disable password expiry for local Windows accounts

  1. Wow, this really saved my day – or rather my night.

    It took me hours of experimenting and nothing helped. And finally I find this…

  2. The domain option can be set to %computername% to make the script a touch more dynamic. Example: cscript “Desktop\nopwdexp.vbs” /domain:%comput
    ername% /user:florist

  3. The script is excellent. There is an alternative for those who can’t/won’t use this script and are running Windows 2003. Just type:

    wmic useraccount where name=”user_name” set PasswordExpires=FALSE

    In a command prompt. WMIC is included on every Windows 2003 version AFAIK.

    (my 2 Maltese cents for as long as they’re worth something)

  4. Thanks for the script it really helped me pull someone who managed the servers out of the gasoline fire :)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.