Batch File user account to Password to Never Expire

Posted on 2007-10-04
Last Modified: 2012-05-05
Hi I have created the batch file below which I want to have password does not expire checkbox ticked in manage local users. We have deployed this batch file and after 2 month the passwords on the PC's started to expire. So I need to amend the batch file below for new PC's and also create another batch file to change the password of the itadmin account and set it to never expire.

below you will notice that the net accounts /maxpwage is set to unlimited, which has not worked for us. I dont know why.

::This create the IT Admin User Account
net user /add ITAdmin MyPassword /fullname:ITAdmin /comment:IT /expires:never
::This assigns the username ITAdmin to have administrative rights
net localgroup administrators ITAdmin /add
::This sets the password to never expire
net accounts /maxpwage:unlimited
Question by:harps21k
    LVL 1

    Expert Comment

    I believe you want net accounts /maxpwage:0  0 in this case means unlimited
    LVL 26

    Accepted Solution

    Greetings Harps21k,
    Have a look at following:

    /maxpwage:{days | unlimited} : Sets the maximum number of days that a user account's password is valid. The unlimited value sets no maximum time.  

    I don't think it can set 'Password Never Expires' attribute.
    For setting this attribute you can use following statement in batch file.

    WMIC USERACCOUNT WHERE "Name='Username'" SET PasswordExpires=FALSE

    Hope this helps!

    Author Comment

    Hi farhankazi,

    Thats Excellent, it works. Also can you help as I want to change the default Administrator account password using a batch file.
    LVL 26

    Expert Comment

    You can change password using NET USER command
    NET USER Administrator P@ssw0rd
                                                    ^----------- New Password for user Administrator

    Author Comment

    Hi farhankazi,

    If I wanted to hide the password from other IT Engineers for security reason when changing the administrator password how would I with the batch cmd below.
    NET USER Administrator P@ssw0rd
    Try to encrypt or hide the password, when changing it. So Engineer cant right click, edit and view it in notepad.
    LVL 26

    Expert Comment

    Actually you can not hide/encrypt password inside batch file. The only option (that i know) is to convert that batch file to .exe format.

    If you convert batch file to executable then its code will not be understandable to users.
    The tool that I use for this purpose is "Bat_To_Exe Converter" (Good one & Freeware)

    Download it from:

    Author Comment

    Thanks farhankazi. Its been very helpful

    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

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Move XP PC to Vmware 22 124
    SQLCMD: launch a .sql with Windows authentication user 6 37
    Vbscript 8 38
    shortcuts on desktops 14 28
    If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
    VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    746 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

    20 Experts available now in Live!

    Get 1:1 Help Now