Multiple Users

  • Thread starter Thread starter Sue
  • Start date Start date
S

Sue

I would like to use a batch file/script to turn on
"Password never expires".
We are getting ready to implemement password policies, but
want to do it a department at a time. So, I want to set
everyone's password to "Password never expires", then turn
on certain departments for troubleshooting control.
Does anyone know of a script that I can use to set
everyone's "Password never expires" all at once?

Thank you in advance.
 
Thank you. I will try it today.
-----Original Message-----

Very quick and very, very dirty (single line):
FOR /F "tokens=1,2,3" %a in ('net user /domain') do net user %a
/EXPIRES:NEVER /DOMAIN

Some error messages because header and footer wouldn't be ignored by the
command.

Ciao, Walter
.
 
Very quick and very, very dirty (single line):
FOR /F "tokens=1,2,3" %a in ('net user /domain') do net user %a
/EXPIRES:NEVER /DOMAIN & net user %b /EXPIRES:NEVER /DOMAIN & net user %c
/EXPIRES:NEVER /DOMAIN

Sorry, the first attempt will only work about 33,3 percent correctly.

Ciao, Walter
 
Okay...when I tried to do this, it only made the user not
expire. I'm trying to stop the password from expiring.

Thank you so much for your help.
-----Original Message-----

FOR /F "tokens=1,2,3" %a in ('net user /domain') do net user %a
/EXPIRES:NEVER /DOMAIN & net user %
b /EXPIRES:NEVER /DOMAIN & net user %c
 
Torgeir Bakken, master scripting dude, provided me with this VBS subroutine
in the WMI newsgroup. You'll need to modify it for your own purposes. It
worked for me on W2K Server and XP Pro. You'll need to get all the usernames
and pass them one by one to the sub. If they are on a different machine
you'll also have to modify the script to accept the machine as a parameter.

Sub NoPwdExpire(sUserName)
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Dim oWshNet, sComputer, oUser, oUserFlags

Set oWshNet = CreateObject("WScript.Network")
sComputer = oWshNet.ComputerName
Set oUser = GetObject("WinNT://" & ThisMachine & "/" & sUserName &
",user")
oUserFlags = oUser.Get("UserFlags")
oUser.Put "UserFlags", oUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
oUser.SetInfo
End Sub
 
Back
Top