Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

1 view
Skip to first unread message

Robert

unread,
Mar 12, 2004, 11:56:52 AM3/12/04
to
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?

wadester

unread,
Mar 12, 2004, 12:23:32 PM3/12/04
to
In article <113f01c40853$04a422f0$3501...@phx.gbl>,
anon...@discussions.microsoft.com wrote...


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

--
The sea was angry that day, my friends. Like an old man, trying to
send back soup at a deli.

anon...@discussions.microsoft.com

unread,
Mar 12, 2004, 2:14:20 PM3/12/04
to
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

>.
>

Mark V

unread,
Mar 13, 2004, 4:20:21 AM3/13/04
to
In microsoft.public.win2000.cmdprompt.admin wrote:

> 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.

wadester

unread,
Mar 15, 2004, 11:17:21 AM3/15/04
to
In article <Xns94AB2C2492...@207.46.248.16>,
notv...@invalid.nul wrote...

> In microsoft.public.win2000.cmdprompt.admin wrote:
>
> > 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.

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

--
How much more black could this be? And the answer is, none. None more
black.

Mark V

unread,
Mar 15, 2004, 2:17:52 PM3/15/04
to
In microsoft.public.win2000.cmdprompt.admin wadester wrote:

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.


wadester

unread,
Mar 16, 2004, 9:15:10 PM3/16/04
to
In article <100901c40866$38a413e0$7d02...@phx.gbl>,
anon...@discussions.microsoft.com says...

> 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

Torgeir Bakken (MVP)

unread,
Mar 16, 2004, 9:43:33 PM3/16/04
to
wadester wrote:

> 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

--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx


Thanatos

unread,
Mar 30, 2004, 2:53:06 AM3/30/04
to
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

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:4057BB55...@hydro.com...

0 new messages