Using batch file to set "Password Never Expires" option for a workgroup user

Posted on 2006-05-30
Last Modified: 2012-06-27
Is it possible to set the "Password Never Expires" option for a workgroup user via a batch file on Windows Server 2003? How can this be done? Thanks.
Question by:Core-D
    LVL 1

    Accepted Solution

    You will have to script this using VB script. You can then incorporate the execution of the script from within your batch file.

    Here is an example script I pulled from .
    There are many useful script examples on this site.

    Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

    strComputer = "atl-win2k-01"
    Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer")

    objUserFlags = objUser.Get("UserFlags")
    objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
    objUser.Put "userFlags", objPasswordExpirationFlag

    Hope this helps.
    LVL 38

    Expert Comment

    mpomery is correct that you can't do this directly through a batch file.  You can, however, turn off expiration for all local user passwords with the following command:
    net accounts /maxpwage:unlimited

    This is a system-wide change that affects all users.  It might not be right for your particular setup, but there are circumstances where it is useful.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction How to create multiboot configuration with XP\Vista and Windows 7 on it? And most important question - how to do this correctly so not to have any kind of nightmares we get when system gets screwed? First of all one should realize t…
    As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, ( because one time I did this and I essentially had a bricked …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now