Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using a .bat file to create a user and password at windows operating system level.

The issue am facing is when i pass EXPIRES:NEVER for password, when the user is created, it doesn't have "Password never expires" checkbox checked (meaning the password never expires is selected for that created user) and the user expires automatically after 90 days.

Net User %1 %2 /COMMENT:"%3" /EXPIRES:NEVER /PASSWORDCHG:NO /ADD

The above is the main line of code, i pass user name and password from a text file and run the .bat file.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Add this line to the batch file:

WMIC USERACCOUNT WHERE "Name='%1'" SET PasswordExpires=FALSE
share|improve this answer
    
NB: I believe that this will only work with LOCAL accounts, not DOMAIN accounts. But it appears that is what you need... –  Glenn Sullivan Oct 4 '12 at 13:59

The option /expires is for account, not for password, check the command help.

http://support.microsoft.com/kb/251394/en-us

share|improve this answer
    
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Scott Pack Oct 16 '12 at 2:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.