prathapml Posted October 15, 2004 Share Posted October 15, 2004 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 >> UsersYou 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 More sharing options...
MHz Posted October 15, 2004 Share Posted October 15, 2004 Have you checked the net command?I think the net account command may do what you want?Here is some info. Link to comment Share on other sites More sharing options...
prathapml Posted October 15, 2004 Author Share Posted October 15, 2004 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 More sharing options...
MHz Posted October 15, 2004 Share Posted October 15, 2004 Found info here and simple info here relating to your issue at Microsoft.Maybe answer within OS? Link to comment Share on other sites More sharing options...
prathapml Posted October 15, 2004 Author Share Posted October 15, 2004 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 More sharing options...
shuter Posted October 15, 2004 Share Posted October 15, 2004 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.SetInfoSet UserObj = Nothing Link to comment Share on other sites More sharing options...
prathapml Posted October 15, 2004 Author Share Posted October 15, 2004 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 More sharing options...
shuter Posted October 15, 2004 Share Posted October 15, 2004 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, objUserOn 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 More sharing options...
prathapml Posted October 15, 2004 Author Share Posted October 15, 2004 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! And now.... any ideas for the being able to specify user name from command-line would be fantastic! Link to comment Share on other sites More sharing options...
shuter Posted October 15, 2004 Share Posted October 15, 2004 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, ArgObjOn 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 IfYou 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 More sharing options...
prathapml Posted October 16, 2004 Author Share Posted October 16, 2004 @shuterYES!!!!!! It is perfect. *EXACTLY* what I was looking for.cscript //B forcepwd.vbs "user name"Thanks a lot! Link to comment Share on other sites More sharing options...
smc1979 Posted October 17, 2004 Share Posted October 17, 2004 If you need any help with any other user admin stuff let me know. I use to be a netowrk admin and had to write a ton of apps. So I can make you just about anything you need. Link to comment Share on other sites More sharing options...
my2001 Posted October 17, 2004 Share Posted October 17, 2004 Cool thing ... I needed that, too ... just a day ago this wish arose. I've been anxious to see the solution of this thread, and here we go. thx 2 shuter! Link to comment Share on other sites More sharing options...
BenjaminKalytta Posted October 17, 2004 Share Posted October 17, 2004 @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 More sharing options...
my2001 Posted October 18, 2004 Share Posted October 18, 2004 @prathapml:odd enough: forcing new passwords for user accounts is already possible using WIHU ... but I didn't know it either. first had to ask WIHU's developer about itone has just to use following ini directive in WIHU: status.x=0x800000this marks the passwords of account no. x as expired Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now