Thursday, October 27, 2005

VBScript to set all local users' passwords to non-expire

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
Wscript.Echo objUser.Name objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo
Next

No comments:

 
Jeffrey Ting Jeffrey Ting on Facebook Jeffrey Ting on Spock Jeffrey Ting on Plaxo Jeffrey Ting on Spoke Jeffrey Ting on LinkedIn