Jump to content

auto-prompt to change password


Recommended Posts

Is there any way to set a user account to forcibly ask them (on next logon) to change their password?

Basically, from:

Computer Management >> System Tools >> Local Users and Groups >> Users

You can click the USERNAME and in "General" tab, you have an option called "User must change password at next logon". I need to have this done unattended - whether from a command-line, or .REG, or some other scripting.

A google search revealed cusrmgr.exe from the Win2k resource kit could do this. Now I'd be damned if it was available in *ANY* of the thousands of sites thrown up as results. So if its available for free download, can someone give a link, or if you know of some other way to do the above, do tell me. Thank you in advance.

Link to comment
Share on other sites


Thanks for the suggestion, but I tried all possibilities in net.exe, and still don't have what I want. My guess is "net user ----" commands are pretty basic in terms of capabilities offered for administration.

Link to comment
Share on other sites

Hehe... that page was totally incomprehensible, lol. (well... no it was useful, but not usable for my purpose).

UPDATE:

Using RegShot, and applying that setting, shows no changes in the registry. So I'm almost convinced that what I need is not in the registry. So I can rule out that one possibility. But still in search of other possibilities, lol.

Link to comment
Share on other sites

Have you thought of using a vbscript?

'********************************
'Name:    ForcePasswordChange.vbs
'Purpose: Force a local user account password
'         change at the next signon
'********************************
Dim objShell, compname, objUser

' *** Place the user account below ***
objUser="Jet"

' *** Get the local computer name ***
Set objShell = CreateObject("wscript.Shell")
compname = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

' *** Bind to the user account and set the expired password flag ***
Set UserObj = GetObject("WinNT://" & compname & "/" & objUser & ", User")
UserObj.Put "PasswordExpired", CLng(1)
UserObj.SetInfo
Set UserObj = Nothing

Link to comment
Share on other sites

Have you thought of using a vbscript?
I did, but promptly stopped thinking, since I realised I did not have any such script with me, lol.

Thanks for the script. Will test it now, and if it works, I will modify it to take a commandline argument of which user to apply it for, or a graphical dialog-box to input the user name. (if you already have modified it to work that way, please do post it). Will let you know how it goes. :)

Link to comment
Share on other sites

Try this. I added a simple input box and error trapping to verify that a valid user name was input.

'********************************
'Name:    ForcePasswordChange.vbs
'Purpose: Force a local user account password
'         change at the next signon
'********************************
Dim objShell, compname, objUser
On Error Resume Next

' *** Place the user account below ***
'objUser="Jet"

' *** Request user name ***
objUser=InputBox("Enter the user name:","Force Password Change")

' *** Get the local computer name ***
Set objShell = CreateObject("wscript.Shell")
compname = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

' *** Bind to the user account and set the expired password flag ***
Set UserObj = GetObject("WinNT://" & compname & "/" & objUser & ", User")
If err.number <> 0 Then
 msgbox("You entered an invalid user.  Exiting script...")
Else
 UserObj.Put "PasswordExpired", CLng(1)
 UserObj.SetInfo
 Set UserObj = Nothing
 txtMsg="User " & objUser & " will now have to change " & vbcrlf
 txtMsg=txtmsg & "his password the next time he logs in."
 msgbox(txtMsg)
End If

Link to comment
Share on other sites

Ha ha ha.... finally! (that's my happiness showing through).

Your first script (3 posts above) works perfectly shuter (not yet tried your above one). Thanks a million. And welcome to MSFN forum! :hello:

And now.... any ideas for the being able to specify user name from command-line would be fantastic! :D

Link to comment
Share on other sites

Okay, the script will now take optional command line arguments. You will probably want to remark out (') the msgbox lines in order to run unattended.

'********************************
'Name:    ForcePasswordChange.vbs
'Purpose: Force a local user account password
'         change at the next signon
'********************************
Dim objShell, compname, objUser, ArgObj
On Error Resume Next

' *** Place the user account below ***
'objUser="Jet"

' *** Request user name (unless passed to the script as an argument)***
If Wscript.Arguments.Count <> 0 Then
 objUser=Wscript.Arguments(0)
Else
 objUser=InputBox("Enter the user name:","Force Password Change")
End If

' *** Get the local computer name ***
Set objShell = CreateObject("wscript.Shell")
compname = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

' *** Bind to the user account and set the expired password flag ***
Set UserObj = GetObject("WinNT://" & compname & "/" & objUser & ", User")
If err.number <> 0 Then
 msgbox("You entered an invalid user.  Exiting script...")
Else
 UserObj.Put "PasswordExpired", CLng(1)
 UserObj.SetInfo
 Set UserObj = Nothing
 txtMsg="User " & objUser & " will now have to change " & vbcrlf
 txtMsg=txtmsg & "his password the next time he logs in."
 msgbox(txtMsg)
End If

You can pass the username as an argument from the command line or batch file like this:

wscript "force password change.vbs" "Jet"

Let me know if you have any problems.

Link to comment
Share on other sites

@prathapml: What is you excat purpose?

Do you only want to change User Account Flags in this way that this user have to change it's account password each logon in future? If I understand you right you don't want set this in "Computer Management >> System Tools >> Local Users and Groups >> Users" but you want this to be done by a script?

I'll create little tool then ;)

Benjamin

Link to comment
Share on other sites

@prathapml:

odd enough: forcing new passwords for user accounts is already possible using WIHU ... but I didn't know it either. :wacko: first had to ask WIHU's developer about it

one has just to use following ini directive in WIHU: status.x=0x800000

this marks the passwords of account no. x as expired

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...