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

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.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

mpomeryConnect With a Mentor Commented:
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.


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.
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.
All Courses

From novice to tech pro — start learning today.