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

[Webinar] Streamline your web hosting managementRegister Today

x
 
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 http://www.cruto.com/resources/vbscript/vbscript-examples/vbscript-sitemap.asp .
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
objUser.SetInfo
----------------------------------------------------------------

Hope this helps.
0
 
Shift-3Commented:
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.
0
All Courses

From novice to tech pro — start learning today.