dslider Posted April 16, 2008 Share Posted April 16, 2008 (edited) From the command line is there a way to uncheck the "Password Never Expires" setting? I am doing this for the LOCAL machine only. I am trying to do this from a bat file that I will be running on computer after it has been syspreped. Any one know they command to do this? Edited April 18, 2008 by dslider Link to comment Share on other sites More sharing options...
neo Posted April 16, 2008 Share Posted April 16, 2008 From the command line is there a way to uncheck the "Password Never Expires" setting? I am doing this for the LOCAL machine only. I am trying to do this from a bat file that I will be running on computer after it has been syspreped. Any one know they command to do this? try this:net accounts /maxpwage:unlimited Link to comment Share on other sites More sharing options...
dslider Posted April 17, 2008 Author Share Posted April 17, 2008 (edited) maybe I was a little vague on my issue..... I need the "Password Never Expires" box to be unchecked.....meaning that the password will expire according to my Group Policy setting.... is there a way to achieve this from the command line? Edited April 17, 2008 by dslider Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted April 17, 2008 Share Posted April 17, 2008 Here is a batch file that uses a vbscript to perform the task:Save this as pwexpire.cmd@echo offif not [%1]==[] ( echo Const ADS_UF_DONT_EXPIRE_PASSWD = ^&H10000 >.\pwexpire.vbs echo Dim User >>.\pwexpire.vbs echo Dim usrflags >>.\pwexpire.vbs echo Set User = GetObject^("WinNT://./%1,user"^) >>.\pwexpire.vbs echo usrflags= User.Get^("UserFlags"^) >>.\pwexpire.vbs echo User.Put "userFlags", usrflags Or ADS_UF_DONT_EXPIRE_PASSWD >>.\pwexpire.vbs echo User.SetInfo >>.\pwexpire.vbs echo Set User = Nothing >>.\pwexpire.vbs cscript //nologo .\pwexpire.vbs if exist .\pwexpire.vbs del .\pwexpire.vbs)Call this batch file like this:pwexpire.cmd userid Link to comment Share on other sites More sharing options...
dslider Posted April 17, 2008 Author Share Posted April 17, 2008 Here is a batch file that uses a vbscript to perform the task:Save this as pwexpire.cmd@echo offif not [%1]==[] ( echo Const ADS_UF_DONT_EXPIRE_PASSWD = ^&H10000 >.\pwexpire.vbs echo Dim User >>.\pwexpire.vbs echo Dim usrflags >>.\pwexpire.vbs echo Set User = GetObject^("WinNT://./%1,user"^) >>.\pwexpire.vbs echo usrflags= User.Get^("UserFlags"^) >>.\pwexpire.vbs echo User.Put "userFlags", usrflags Or ADS_UF_DONT_EXPIRE_PASSWD >>.\pwexpire.vbs echo User.SetInfo >>.\pwexpire.vbs echo Set User = Nothing >>.\pwexpire.vbs cscript //nologo .\pwexpire.vbs if exist .\pwexpire.vbs del .\pwexpire.vbs)Call this batch file like this:pwexpire.cmd useridThis does not uncheck the "Password never Expires" box... but it will check it for you.. how can I make it uncheck the box? Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted April 17, 2008 Share Posted April 17, 2008 Oops! Sorry about that. Here is a correction:@echo offif not [%1]==[] ( echo Const ADS_UF_EXPIRE_PASSWD = ^&H01111 >.\pwexpire.vbs echo Dim User >>.\pwexpire.vbs echo Dim usrflags >>.\pwexpire.vbs echo Set User = GetObject^("WinNT://./%1,user"^) >>.\pwexpire.vbs echo usrflags= User.Get^("UserFlags"^) >>.\pwexpire.vbs echo User.Put "userFlags", usrflags AND ADS_UF_EXPIRE_PASSWD >>.\pwexpire.vbs echo User.SetInfo >>.\pwexpire.vbs echo Set User = Nothing >>.\pwexpire.vbs cscript //nologo .\pwexpire.vbs if exist .\pwexpire.vbs del .\pwexpire.vbs) Link to comment Share on other sites More sharing options...
TheFlash428 Posted April 17, 2008 Share Posted April 17, 2008 Oops! Sorry about that. Here is a correction:@echo offif not [%1]==[] ( echo Const ADS_UF_EXPIRE_PASSWD = ^&H01111 >.\pwexpire.vbs echo Dim User >>.\pwexpire.vbs echo Dim usrflags >>.\pwexpire.vbs echo Set User = GetObject^("WinNT://./%1,user"^) >>.\pwexpire.vbs echo usrflags= User.Get^("UserFlags"^) >>.\pwexpire.vbs echo User.Put "userFlags", usrflags AND ADS_UF_EXPIRE_PASSWD >>.\pwexpire.vbs echo User.SetInfo >>.\pwexpire.vbs echo Set User = Nothing >>.\pwexpire.vbs cscript //nologo .\pwexpire.vbs if exist .\pwexpire.vbs del .\pwexpire.vbs)I've been trying to figure out a way to do this myself for a while. Thanks!Also, if you need to set the "password required", that can be done by:NET USER [username] /PASSWORDREQ:YES Link to comment Share on other sites More sharing options...
neo Posted April 18, 2008 Share Posted April 18, 2008 From the command line is there a way to uncheck the "Password Never Expires" setting? I am doing this for the LOCAL machine only. I am trying to do this from a bat file that I will be running on computer after it has been syspreped. Any one know they command to do this? try this:net accounts /maxpwage:unlimitedoh....I missed Sorrynet accounts /maxpwage:<DAYS>You can write days as desired. Link to comment Share on other sites More sharing options...
dslider Posted April 18, 2008 Author Share Posted April 18, 2008 I am having an issue with calling this from within another bat script....its in my other bat script liek the following:C:\windows\securityscript\pwexpire.cmd HelpAssistantC:\windows\securityscript\pwexpire.cmd Guestbut it throws an error saying the file or directory cant be found...... says the error is at pwexpire.vbs(7,1) .... what am I doing wrong when I call this file?and yes it is going to the correct directory to run the file... Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 18, 2008 Share Posted April 18, 2008 Read this page as it deals with using VBS script and Local User Accounts.Vbs Script Local Users Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted April 19, 2008 Share Posted April 19, 2008 I am having an issue with calling this from within another bat script....its in my other bat script liek the following:C:\windows\securityscript\pwexpire.cmd HelpAssistantC:\windows\securityscript\pwexpire.cmd Guestbut it throws an error saying the file or directory cant be found...... says the error is at pwexpire.vbs(7,1) .... what am I doing wrong when I call this file?and yes it is going to the correct directory to run the file...OK, I am not able to reproduce this error . I provided you with pwexpire2.vbs for you to run directlyinstead of creating it within the batch file.Your result was:it just gives me a blank error now.My result: desired user account(s) set to must change password.I provided you with AllUserPWExpire.vbs to see if the scriptwould set all user accounts to must change password.Your result was:OK I got it kinda working.... the accounts that are disabledstill dont change and it still throws an error after it runs...."C:\Windows\securityfolder\pwexpire.vbs(16,9) (null):The filename, directory name, or volume label syntax is incorrect."My result: All user accounts set to must change password.I hope someone else can reproduce the error and shed somelight on a solution.The attached file contains the two scripts mentioned.PWExpire.zip Link to comment Share on other sites More sharing options...
dslider Posted April 21, 2008 Author Share Posted April 21, 2008 the script works on all accounts but the accounts that are already disabled.... if I enable the account the script works without any errors... any one know why this is? 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