Is there a command to check the expiration date/ time for a local user account

R

Robert

Is there a command to check the expiration date/ time for
a local user account. Maybe a registry entry even? I am
creating an automated user creation tool and I am using
the /expire:no option but it isn't checking the box for
Password Never expires so I want to verify that it will
not expire. Make since?
 
W

wadester

Is there a command to check the expiration date/ time for
a local user account. Maybe a registry entry even? I am
creating an automated user creation tool and I am using
the /expire:no option but it isn't checking the box for
Password Never expires so I want to verify that it will
not expire. Make since?


I think the syntax is "/expires:NEVER", which could explain why your
does appear to work.

Here's a VBScript that will check it (requires WMI, replace xxxxx
with the account name):

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32
_UserAccount where name='xxxxx'",,48)
For Each objItem in colItems
Wscript.Echo "For user " & objItem.Name & ", PasswordExpires is
set to " & objItem.PasswordExpires
Next

ws
 
G

Guest

I tried the "/expires:NEVER" also but it still doesn't add
the check. Maybe I need to put it in a certain area of
the net user command. Here is an example of my command
line. net user testuser
testpassword /add /expires:"never" /Comment:"Test
Account" /FullName:"Tester" /passwordchg:"no"

Everything seems to work in the command but the password
never expires check doesn't become checked off. I also
tried the same command line with the "/expires:NEVER" also
but it didn't work. I would like to check to see if the
change still took place but I know nothing about wmi or
vbscripts. Rockie when it comes to vbscripts. Thanks
 
M

Mark V

In said:
I tried the "/expires:NEVER" also but it still doesn't add
the check. Maybe I need to put it in a certain area of
the net user command. Here is an example of my command
line. net user testuser
testpassword /add /expires:"never" /Comment:"Test
Account" /FullName:"Tester" /passwordchg:"no"

Try doing it in two pieces. First actually create the account, then
once it exists make the other chnages. Used to be the case anyway.
 
W

wadester

Try doing it in two pieces. First actually create the account, then
once it exists make the other chnages. Used to be the case anyway.

Well, my reply never posted from the weekend...the "expires" with NET
USER sets the *account* to not expire, not the password. Google
around for some 3rd party command line utils for this.

ws
 
M

Mark V

In said:
Well, my reply never posted from the weekend...the "expires" with
NET USER sets the *account* to not expire, not the password.
Google around for some 3rd party command line utils for this.

Oh. I mis-read your intent.
The PWD length and Expiration is global. See
net help accounts

PWD complexity is also global but AFAIK cannot be set using net.exe.
 
W

wadester

I tried the "/expires:NEVER" also but it still doesn't add
the check. Maybe I need to put it in a certain area of
the net user command. Here is an example of my command
line. net user testuser
testpassword /add /expires:"never" /Comment:"Test
Account" /FullName:"Tester" /passwordchg:"no"


Actually, this "expires" option sets the ACCOUNT not to expire, not the
password. You can't control password expiration using NET USER.

There seem to be a lot of command line utils and VBScripts around to
address this. Do a Google search - there appear to be quite a few, and
you can choose the one that best suits your needs (sorry, I was going
to post some, but there are too many!)

ws
 
T

Torgeir Bakken (MVP)

wadester said:
Actually, this "expires" option sets the ACCOUNT not to expire, not the
password. You can't control password expiration using NET USER.

There seem to be a lot of command line utils and VBScripts around to
address this. Do a Google search - there appear to be quite a few, and
you can choose the one that best suits your needs (sorry, I was going
to post some, but there are too many!)

Hi

Tip 570 at for a freeware command line tool (NETUSER.EXE):
http://www.jsiinc.com/reghack.htm

Example:

NETUSER.EXE someuser /pwnexp:y
 
T

Thanatos

CUSRMGR (command line user manager) from the Windows 2000 Reskit will allow
you to set the expire flag.

This sets the flag: CUSRMGR -u username -m \\machine +s
PasswordNeverExpires
This removes the flag: CUSRMGR -u username -m \\machine -s
PasswordNeverExpires

You can also set/remove the AccountLockout flag with this tool and a lot
more.

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top