PcExpert Posted June 15, 2007 Share Posted June 15, 2007 Hi all,I was wondering if its possible to make 2 inputboxes where the user specifies name and password. And the program sets that account as the autologon account. I found this:http://wwtw.autoitscript.com/forum/index.p...;hl=create+userBut that only lets you choose a username not a passwords.Thanks in advance! Link to comment Share on other sites More sharing options...
PcExpert Posted June 15, 2007 Author Share Posted June 15, 2007 Somebody, please Link to comment Share on other sites More sharing options...
Developers Jos Posted June 15, 2007 Developers Share Posted June 15, 2007 (edited) don;t know what post you tried to link to but this script will create a local account .. Just add the Inputboxes. ; Init objects $UserName = 'Fred' $Password = 'Wil"ma' $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler $strComputer = @ComputerName $colAccounts = ObjGet("WinNT://" & $strComputer & "") ;$objGroup = ObjGet("WinNT://" & $strComputer & "/Users,group") ; Read in lines of text until the EOF is reached $objUser = $colAccounts.Create("user", $UserName) $objUser.SetPassword ($Password) $objUser.Put ("Fullname", "Test User") $objUser.Put ("Description", "Test User description") $objUser.SetInfo ;Add user to 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 Edited June 15, 2007 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 More sharing options...
Mast3rpyr0 Posted June 16, 2007 Share Posted June 16, 2007 oo i think i may use that error function. il be sure to give you credit for it jdeb My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
PcExpert Posted June 16, 2007 Author Share Posted June 16, 2007 Thanks JdeB! How to delete the account if everything is finished? Link to comment Share on other sites More sharing options...
Developers Jos Posted June 16, 2007 Developers Share Posted June 16, 2007 (edited) Thanks JdeB! How to delete the account if everything is finished?Here is a complete example to Create/Rename/Delete an Local account: expandcollapse popup; Init objects $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler $UserName = 'Fred' $Password = 'Wilma123' $strComputer = @ComputerName ;*********************** ;Create UserID $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) ;*********************** ; Rename User $colAccounts = ObjGet("WinNT://" & $strComputer & "") $objUser = $colAccounts.Create("user", $UserName) $OldUser = "Fred" $NewUser = "Fredrenamed" $oUser = ObjGet("WinNT://" & @ComputerName & "/" & $OldUser & ",user") $oComputer = ObjGet("WinNT://" & @ComputerName) $oNewUser = $oComputer.MoveHere($oUser.ADsPath, $NewUser) MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$oNewUser' & @lf & @lf & 'Return:' & @lf & $oNewUser & @lf & @lf & '@Error:' & @lf & @Error) ;### Debug MSGBOX ; Delete User $colAccounts = ObjGet("WinNT://" & $strComputer & "") $objUser = $colAccounts.Delete("user", $NewUser) 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 Edited June 16, 2007 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 More sharing options...
star2 Posted June 16, 2007 Share Posted June 16, 2007 one silly question can I get a list of user names? [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
Developers Jos Posted June 16, 2007 Developers Share Posted June 16, 2007 one silly question can I get a list of user names?$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler Local $objDomain = ObjGet("WinNT://" & @ComputerName & "" ) ;Set objDomain = GetObject("WinNT://domainname,domain") Dim $filter[2] = ["user"] $objDomain.Filter = $filter For $aUser In $objDomain ConsoleWrite($aUSer.Name & "|" & $aUSer.Description & @LF) Next ;COM Error function Func ComError() If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) ConsoleWrite($oMyError.scriptline & ' $HexNumber = ' & $HexNumber & "Windescription is: " & $oMyError.description & "|" & $oMyError.windescription & @lf) ;### Debug Console SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc ;==>ComError 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 More sharing options...
star2 Posted June 16, 2007 Share Posted June 16, 2007 thanks boss [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
PcExpert Posted June 16, 2007 Author Share Posted June 16, 2007 Thanks JdeB! Works Fine now Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now