Jump to content

Creating a new User account


Recommended Posts

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?

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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.
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...