Jump to content

user creation


Recommended Posts

hello all

i 've got a script to create a new 'user'.

; add user accounts
; Author - MHz
;#cs
_NetUser('Jack', 'pw_abc')
_NetUser('Jill', 'pw_def')

Func _NetUser($name, $password = '', $groupname = 'Administrators', $autologon = 0)
; Creates user accounts. Only 1 user can have autologon, if set.
    Local $key

    If Not FileExists(EnvGet('AllUsersProfile') & '\..\' & $name) Then
        RunWait(@ComSpec & ' /c ' & _
                'Net User ' & $name & ' ' & $password & ' /add &&' & _
                'Net LocalGroup ' & $groupname & ' ' & $name & ' /add &' & _
                'Net Accounts /MaxPwAge:UnLimited', '', @SW_HIDE)
        If $autologon Then
            $key = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
            RegWrite($key, 'DefaultUserName', 'Reg_sz', $name)
            RegWrite($key, 'DefaultPassword', 'Reg_sz', $password)
            RegWrite($key, 'AutoAdminLogon', 'Reg_sz', 1)
        EndIf
    EndIf
    EndFunc

at the link user creation

please tell me in "Properties" of the user how to add ''Password Never Expires'' at the tab ''General''. >_<

thanx in advance

Edited by randeep

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Link to comment
Share on other sites

Try these commands:

WMIC USERACCOUNT WHERE "Name='username_here'" SET PasswordExpires=FALSE

OR

net user username_here /expires:never

Found on Google on first result. Google query was "set user to never expire password command line".

thanx for replying but both of them are not working.

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Link to comment
Share on other sites

  • 3 weeks later...

thanx for replying but both of them are not working.

The reason this is happening is because the NET ACCOUNTS command is for changing the local user policy to pertaining to account creation. When you force that command you are changing ALL accounts to have their password never expire. Because it is set through policy, you wont see the checkbox checked, but it probably won't expire. I haven't tested it, but that is what I can gather from reading about the command itself.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...