Change Local account password never expires flag programatically

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

Does anyone know how to change Local account password never expires
flag programmatically, VBScript preferably.
 
Bruce said:
Does anyone know how to change Local account password never expires
flag programmatically, VBScript preferably.
Hi,

A)

With VBScript and the WinNT provider:


For all local users on a computer:

'--------------------8<----------------------

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

' create network object for the local computer
Set objNetwork = CreateObject("Wscript.Network")

' get the name of the local computer
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("WinNT://" & strComputer)
objComputer.Filter = Array("user")

For Each objUser In objComputer
lngUserFlags = objUser.userFlags
lngUserFlags = lngUserFlags Or ADS_UF_DONT_EXPIRE_PASSWD
objUser.userFlags = lngUserFlags
objUser.SetInfo
Next
'--------------------8<----------------------



For a specific user account:

'--------------------8<----------------------

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

strUser = "SomeUserNameHere"

' create network object for the local computer
Set objNetwork = CreateObject("Wscript.Network")

' get the name of the local computer
strComputer = objNetwork.ComputerName

Set objUser = GetObject("WinNT://" & _
strComputer & "/" & strUser & ",User")

lngUserFlags = objUser.userFlags
lngUserFlags = lngUserFlags Or ADS_UF_DONT_EXPIRE_PASSWD
objUser.userFlags = lngUserFlags
objUser.SetInfo

'--------------------8<----------------------



B)
Command line:

Tip 570 at for a freeware command line tool (NETUSER.EXE):
http://www.jsiinc.com/reghack.htm

This should do it then:

NETUSER.EXE jeanette /pwnexp:y
 
Back
Top