PC Review


Reply
Thread Tools Rate Thread

Change Local account password never expires flag programatically

 
 
Bruce
Guest
Posts: n/a
 
      16th Feb 2006
Does anyone know how to change Local account password never expires
flag programmatically, VBScript preferably.

 
Reply With Quote
 
 
 
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a
 
      16th Feb 2006
Bruce wrote:

> 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




--
torgeir, Microsoft MVP Scripting, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scr...r/default.mspx
 
Reply With Quote
 
Bruce
Guest
Posts: n/a
 
      16th Feb 2006
Thanks a bunch!!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing a Service Account Password programatically Adrian Dev Microsoft C# .NET 0 8th Aug 2006 05:30 PM
How to enable Password Expires for the Local Guest account? =?Utf-8?B?dmlsbGFnb2Q=?= Windows XP Accessibility 3 23rd Mar 2006 05:59 PM
Change Local account password never expires flag programatically Bruce Windows XP Setup 0 14th Feb 2006 09:02 PM
Change hundred Machine's local account password Alan Tang Microsoft Windows 2000 CMD Promt 1 26th Jan 2006 01:07 PM
Password expires and account state changes to "user must change password on next logon" dmohanty@gmail.com Microsoft Windows 2000 Active Directory 0 13th Sep 2005 10:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:27 AM.