Sign in to follow this  
Followers 0
malchai

Creating a new User account

5 posts in this topic

I have been working on a script to automate setting up a computer at work and ran into some walls while trying to create User Accounts. It appears that the normal User Accounts section in Control Panel doesnt really have buttons and much as links. To further compound my problem, they bought Home Edition computers which dont show the user management in computer management. I have a file Addusers.exe which doesnt seem to do what i want. So the question is...has anyone done a script for this, or is there some way to interface with that web like control panel area?

Share this post


Link to post
Share on other sites



I have been working on a script to automate setting up a computer at work and ran into some walls while trying to create User Accounts. It appears that the normal User Accounts section in Control Panel doesnt really have buttons and much as links. To further compound my problem, they bought Home Edition computers which dont show the user management in computer management. I have a file Addusers.exe which doesnt seem to do what i want. So the question is...has anyone done a script for this, or is there some way to interface with that web like control panel area?

you could use "Net User" command or try this script:

; Init objects
$UserName = 'Fred'
$Password = 'Wilma123'
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler 
$strComputer = @ComputerName
$colAccounts = ObjGet("WinNT://" & $strComputer & "")
$objUser = $colAccounts.Create("user", $UserName)
$objUser.SetPassword ($Password)
$objUser.Put ("Fullname", "Test User")
$objUser.Put ("Description", "Test User description")
$objUser.Put ("PasswordExpired", 1)  ;expire the password
$objUser.SetInfo

;Add User to group 
;$objGroup = ObjGet("WinNT://" & $strComputer & "/Administrators,group")
;$objGroup.Add($objUser.ADsPath)
;
;
; This is my custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Linenbr is: " & $oMyError.scriptline  & @CRLF & _
                "Description is: " & $oMyError.description  & @CRLF & _
                "Windescription is: " & $oMyError.windescription ) 

   SetError(1) ; something to check for when this function returns 
Endfunc

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Can't get that script to work but i like the Net user tool. Do you happen to k now hot to flag the new user as an Administrator instead of a limited user?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Can't get that script to work ...

Are you using the AutoIt3 Beta version?

Do you happen to k now hot to flag the new user as an Administrator instead of a limited user?

The user needs to be added to the Administrators group.... (currently commented in the script)

This is also possible with a Net Group command

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Are you using the AutoIt3 Beta version?

The user needs to be added to the Administrators group.... (currently commented in the script)

This is also possible with a Net Group command

Nope, need to get the Beta version i suppose. thanks.

Share this post


Link to post
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
Sign in to follow this  
Followers 0