Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



net user password never expires option

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 22-09-2006
network admin in need of help
 
Posts: n/a
net user password never expires option

i am using net user batch file to create and add 142 user, i need to use the
password never expires option, but i am running into an issue, here is what i
have

net user ons1 #!wdfons1 /add /expires:never /passwordchg:no

the result of this is the line saying the comand completed successfully,
however when i look at the user properties, i see that the user cannot change
password selection is marked, but the password nerver expires box is not
marked.

i am running this on windows 2000 server

what have i done wrong. any help would be greatly appreciated.


Reply With Quote
  #2  
Old 23-09-2006
Michael Harris \(MVP\)
 
Posts: n/a
Re: net user password never expires option

network admin in need of help wrote:
> i am using net user batch file to create and add 142 user, i need to
> use the password never expires option, but i am running into an
> issue, here is what i have
>
> net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
>
> the result of this is the line saying the comand completed
> successfully, however when i look at the user properties, i see that
> the user cannot change password selection is marked, but the password
> nerver expires box is not marked.
>
> i am running this on windows 2000 server
>
> what have i done wrong. any help would be greatly appreciated.



Per C:\>net user /help

/expires:never would apply to the user account expiration, not the password.

Try this Jerold Schulman solution...

JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
'Password never expires' on or off?
<http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>

--
Michael Harris
Microsoft MVP Scripting


Reply With Quote
  #3  
Old 23-09-2006
brian metzger
 
Posts: n/a
Re: net user password never expires option



"Michael Harris (MVP)" wrote:

> network admin in need of help wrote:
> > i am using net user batch file to create and add 142 user, i need to
> > use the password never expires option, but i am running into an
> > issue, here is what i have
> >
> > net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
> >
> > the result of this is the line saying the comand completed
> > successfully, however when i look at the user properties, i see that
> > the user cannot change password selection is marked, but the password
> > nerver expires box is not marked.
> >
> > i am running this on windows 2000 server
> >
> > what have i done wrong. any help would be greatly appreciated.

>
>
> Per C:\>net user /help
>
> /expires:never would apply to the user account expiration, not the password.
>
> Try this Jerold Schulman solution...
>
> JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
> 'Password never expires' on or off?
> <http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>
>
> --
> Michael Harris
> Microsoft MVP Scripting
>
>
> thank you for your assistance.


this does not look like it is working for me. it may just be me, i am new to
scripting, i have written 3 .vbs and about 5 .bat and i am still an infant at
it, learning more and more each day. can you explain to me what i would need
to do to set it to work for me, or is there a line or 2 out of it that i need
to incorporate into the script that i have?

thanks again
brian metzger
Reply With Quote
  #4  
Old 23-09-2006
Jerold Schulman
 
Posts: n/a
Re: Re: net user password never expires option

On Sat, 23 Sep 2006 06:07:01 -0700, brian metzger <brianmetzger@discussions.microsoft.com> wrote:

>
>
>"Michael Harris (MVP)" wrote:
>
>> network admin in need of help wrote:
>> > i am using net user batch file to create and add 142 user, i need to
>> > use the password never expires option, but i am running into an
>> > issue, here is what i have
>> >
>> > net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
>> >
>> > the result of this is the line saying the comand completed
>> > successfully, however when i look at the user properties, i see that
>> > the user cannot change password selection is marked, but the password
>> > nerver expires box is not marked.
>> >
>> > i am running this on windows 2000 server
>> >
>> > what have i done wrong. any help would be greatly appreciated.

>>
>>
>> Per C:\>net user /help
>>
>> /expires:never would apply to the user account expiration, not the password.
>>
>> Try this Jerold Schulman solution...
>>
>> JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
>> 'Password never expires' on or off?
>> <http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>
>>
>> --
>> Michael Harris
>> Microsoft MVP Scripting
>>
>>
>> thank you for your assistance.

>
>this does not look like it is working for me. it may just be me, i am new to
>scripting, i have written 3 .vbs and about 5 .bat and i am still an infant at
>it, learning more and more each day. can you explain to me what i would need
>to do to set it to work for me, or is there a line or 2 out of it that i need
>to incorporate into the script that i have?
>
>thanks again
>brian metzger


Where is it failing?
Did you change the @echo off to @echo on, remove the >nul 2>&1
and log the output?


Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
Reply With Quote
  #5  
Old 23-09-2006
brian metzger
 
Posts: n/a
Re: Re: net user password never expires option



"Jerold Schulman" wrote:

> On Sat, 23 Sep 2006 06:07:01 -0700, brian metzger <brianmetzger@discussions.microsoft.com> wrote:
>
> >
> >
> >"Michael Harris (MVP)" wrote:
> >
> >> network admin in need of help wrote:
> >> > i am using net user batch file to create and add 142 user, i need to
> >> > use the password never expires option, but i am running into an
> >> > issue, here is what i have
> >> >
> >> > net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
> >> >
> >> > the result of this is the line saying the comand completed
> >> > successfully, however when i look at the user properties, i see that
> >> > the user cannot change password selection is marked, but the password
> >> > nerver expires box is not marked.
> >> >
> >> > i am running this on windows 2000 server
> >> >
> >> > what have i done wrong. any help would be greatly appreciated.
> >>
> >>
> >> Per C:\>net user /help
> >>
> >> /expires:never would apply to the user account expiration, not the password.
> >>
> >> Try this Jerold Schulman solution...
> >>
> >> JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
> >> 'Password never expires' on or off?
> >> <http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>
> >>
> >> --
> >> Michael Harris
> >> Microsoft MVP Scripting
> >>
> >>
> >> thank you for your assistance.

> >
> >this does not look like it is working for me. it may just be me, i am new to
> >scripting, i have written 3 .vbs and about 5 .bat and i am still an infant at
> >it, learning more and more each day. can you explain to me what i would need
> >to do to set it to work for me, or is there a line or 2 out of it that i need
> >to incorporate into the script that i have?
> >
> >thanks again
> >brian metzger

>
> Where is it failing?
> Did you change the @echo off to @echo on, remove the >nul 2>&1
> and log the output?
>
>
> Jerold Schulman
> Windows Server MVP
> JSI, Inc.
> http://www.jsiinc.com
> http://www.jsifaq.com


i did not, i have now, this is what i have

@echo on
setlocal
if {%2}=={} goto err
set ons1=%1
set YN=%2
set /a pnx=65536
set /a upnx=0
if /i "%YN%" EQU "Y" goto swok
if /i "%YN%" NEQ "N" goto err
:swok
set /a userAccountControl=999999999
call :getusr
if %userAccountControl% EQU 999999999 goto usrnf
if /i "%YN%" EQU "N" goto setoff
set /a upnx=%userAccountControl% ^& %pnx%
if %upnx% EQU %pnx% goto finish
set /a userAccountControl=%userAccountControl% ^| 65536
call :updusr>
goto finish
:setoff
set /a upnx=%userAccountControl% ^& %pnx%
if %upnx% NEQ %pnx% goto finish
set /a userAccountControl=%userAccountControl% ^^ 65536
call :updusr
:finish
endlocal
goto :EOF
:err
@echo Syntax: PwdNX ons1 Y^|N
endlocal
:usrnf
@echo Syntax: PwdNX ons1 Y^|N - %ons1% NOT found.
endlocal
goto :EOF
:getusr
for /f "Tokens=2 Delims=: " %%a in ('adfind -b %ons1% -nodn -noctl
userAccountControl^|find /i "userAccountControl"') do (
set /a userAccountControl=%%a
)
goto :EOF
:updusr
admod -b %ons1% "userAccountControl::%userAccountControl%"



this is what the results are:
the user name i am testing is ons1

password never expires option is still not checked.

and the cmd prompt shows the following

i ran from cmd prompt

c:\>pwdnvrx.bat
(this is the result)
c:\>setlocal

c:\>if {} == {} goto err
syntax PwdNX ons1 Y:N

c:\>endlocal
Syntax: PwdNX ons1 Y:N - NOT found.

c:\>endlocal

c:\>goto :EOF

c:\>

what have i messed up.
thanks for your help
brian metzger




>

Reply With Quote
  #6  
Old 24-09-2006
Jerold Schulman
 
Posts: n/a
Re: Re: Re: net user password never expires option

On Sat, 23 Sep 2006 07:17:02 -0700, brian metzger <brianmetzger@discussions.microsoft.com> wrote:

>
>
>"Jerold Schulman" wrote:
>
>> On Sat, 23 Sep 2006 06:07:01 -0700, brian metzger <brianmetzger@discussions.microsoft.com> wrote:
>>
>> >
>> >
>> >"Michael Harris (MVP)" wrote:
>> >
>> >> network admin in need of help wrote:
>> >> > i am using net user batch file to create and add 142 user, i need to
>> >> > use the password never expires option, but i am running into an
>> >> > issue, here is what i have
>> >> >
>> >> > net user ons1 #!wdfons1 /add /expires:never /passwordchg:no
>> >> >
>> >> > the result of this is the line saying the comand completed
>> >> > successfully, however when i look at the user properties, i see that
>> >> > the user cannot change password selection is marked, but the password
>> >> > nerver expires box is not marked.
>> >> >
>> >> > i am running this on windows 2000 server
>> >> >
>> >> > what have i done wrong. any help would be greatly appreciated.
>> >>
>> >>
>> >> Per C:\>net user /help
>> >>
>> >> /expires:never would apply to the user account expiration, not the password.
>> >>
>> >> Try this Jerold Schulman solution...
>> >>
>> >> JSI Tip 9625. How can a batch set a user's UserAccountControl attribute for
>> >> 'Password never expires' on or off?
>> >> <http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9625>
>> >>
>> >> --
>> >> Michael Harris
>> >> Microsoft MVP Scripting
>> >>
>> >>
>> >> thank you for your assistance.
>> >
>> >this does not look like it is working for me. it may just be me, i am new to
>> >scripting, i have written 3 .vbs and about 5 .bat and i am still an infant at
>> >it, learning more and more each day. can you explain to me what i would need
>> >to do to set it to work for me, or is there a line or 2 out of it that i need
>> >to incorporate into the script that i have?
>> >
>> >thanks again
>> >brian metzger

>>
>> Where is it failing?
>> Did you change the @echo off to @echo on, remove the >nul 2>&1
>> and log the output?
>>
>>
>> Jerold Schulman
>> Windows Server MVP
>> JSI, Inc.
>> http://www.jsiinc.com
>> http://www.jsifaq.com

>
>i did not, i have now, this is what i have
>
>@echo on
>setlocal
>if {%2}=={} goto err
>set ons1=%1
>set YN=%2
>set /a pnx=65536
>set /a upnx=0
>if /i "%YN%" EQU "Y" goto swok
>if /i "%YN%" NEQ "N" goto err
>:swok
>set /a userAccountControl=999999999
>call :getusr
>if %userAccountControl% EQU 999999999 goto usrnf
>if /i "%YN%" EQU "N" goto setoff
>set /a upnx=%userAccountControl% ^& %pnx%
>if %upnx% EQU %pnx% goto finish
>set /a userAccountControl=%userAccountControl% ^| 65536
>call :updusr>
>goto finish
>:setoff
>set /a upnx=%userAccountControl% ^& %pnx%
>if %upnx% NEQ %pnx% goto finish
>set /a userAccountControl=%userAccountControl% ^^ 65536
>call :updusr
>:finish
>endlocal
>goto :EOF
>:err
>@echo Syntax: PwdNX ons1 Y^|N
>endlocal
>:usrnf
>@echo Syntax: PwdNX ons1 Y^|N - %ons1% NOT found.
>endlocal
>goto :EOF
>:getusr
>for /f "Tokens=2 Delims=: " %%a in ('adfind -b %ons1% -nodn -noctl
>userAccountControl^|find /i "userAccountControl"') do (
> set /a userAccountControl=%%a
>)
>goto :EOF
>:updusr
>admod -b %ons1% "userAccountControl::%userAccountControl%"
>
>
>
>this is what the results are:
>the user name i am testing is ons1
>
>password never expires option is still not checked.
>
>and the cmd prompt shows the following
>
>i ran from cmd prompt
>
>c:\>pwdnvrx.bat
>(this is the result)
>c:\>setlocal
>
>c:\>if {} == {} goto err
>syntax PwdNX ons1 Y:N
>
>c:\>endlocal
>Syntax: PwdNX ons1 Y:N - NOT found.
>
>c:\>endlocal
>
>c:\>goto :EOF
>
>c:\>
>
>what have i messed up.
>thanks for your help
>brian metzger
>
>
>
>
>>


Are you being funny or just dense?

1. DO NOT modify the batch file. Copy/Paste it just as it is.
2. At the CMD.EXE prompt, type:
pwdnx UserDN Y
where UserDN is the distinguished name of ons1.

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "net user password never expires option"
Thread Thread Starter Forum Replies Last Post
How to reset User Password via single user mode in mac os x Jay Scott Operating Systems 3 10-11-2010 07:00 PM
List all users with 'Password Never Expires' Tirana Active Directory 4 03-09-2009 06:56 AM
domain user password expired but user not prompted to change passw GunTher Active Directory 1 28-07-2008 11:53 AM
How to force User log off when time expires? TheTurner Windows Security 2 28-07-2007 06:32 AM
Windows Login password fails. Can switch user without getting login screen and bypass password !?!?!? Gaffigana Windows XP Support 1 28-04-2007 08:57 PM


All times are GMT +5.5. The time now is 10:59 PM.