One of the shortcomings of the net user
command in Windows is the inability to set the password never expires flag on an account (account expiry options can be set, but not password expiry and the full syntax is described in Microsoft knowledge base article 251394).
There are 13 flags on an NT SAM/Active Directory user account which may be manipulated using VBScript (for further details of the 13 flags, see Microsoft’s sample scripts or there is some useful information about the object model at the Motobit Software website).
This script can be used to set the password never expires flag on a specified account. I’ve tested it against the local SAM database on a Windows XP PC, but in theory it should work on all versions of Windows NT (2000, XP, 2003 Server, etc.) and also against Active Directory accounts if you run it on a domain controller.
Wow, this really saved my day – or rather my night.
It took me hours of experimenting and nothing helped. And finally I find this…
The domain option can be set to %computername% to make the script a touch more dynamic. Example: cscript “Desktop\nopwdexp.vbs” /domain:%comput
ername% /user:florist
Great, I’ve been looking for this for years! Thanks a lot!
Thank you for the script – works a treat & saved me some effort.
Cheers.
The script is excellent. There is an alternative for those who can’t/won’t use this script and are running Windows 2003. Just type:
wmic useraccount where name=”user_name” set PasswordExpires=FALSE
In a command prompt. WMIC is included on every Windows 2003 version AFAIK.
(my 2 Maltese cents for as long as they’re worth something)
I’m glad it came in useful guys and thanks Mark (Bishop) for the WMIC tip.
Mark
I found the answer to setting the password to never expire, thanks to Mark Bishop, using the WMIC.
Thanks. This VB-script really helped me out.
Thanks for the script it really helped me pull someone who managed the servers out of the gasoline fire :)
Thanks Mark! That saved me LOTS of time :)
Wov, this has saved me hell a lot of time
Thanks a lot Mark