mrrlg Posted February 7, 2006 Share Posted February 7, 2006 I have been banging my head against the wall for days now trying to figure out how to add 300 users as local users to a Windows 2003 server. The original post is #143645. What I need to do is copy from a .cvs file the user's first and last name, their logon name and their password. The only bit of code that has worked for me has been this bit of vbs script. strComputer = "sdsnawp2" Set colAccounts = GetObject("WinNT://" & strComputer & "") Set objUser = colAccounts.Create("user", "aesparza") Set objGroup = GetObject("WinNT://" & strComputer & "/Users,group") objUser.SetPassword "mj679s" objUser.SetInfo objGroup.Add(objUser.ADsPath) I can't seem to figure out how to apply any of the autoit scripts offered in the post mentioned above to solve this problem. Link to comment Share on other sites More sharing options...
Methos Posted February 7, 2006 Share Posted February 7, 2006 Well, something like this is usually much easier done with a command line, not to say it can't be done in autoit. If you are just trying to get this done once, definately easier done in DOS. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 7, 2006 Developers Share Posted February 7, 2006 (edited) I have been banging my head against the wall for days now trying to figure out how to add 300 users as local users to a Windows 2003 server. The original post is #143645. What I need to do is copy from a .cvs file the user's first and last name, their logon name and their password. The only bit of code that has worked for me has been this bit of vbs script. strComputer = "sdsnawp2" Set colAccounts = GetObject("WinNT://" & strComputer & "") Set objUser = colAccounts.Create("user", "aesparza") Set objGroup = GetObject("WinNT://" & strComputer & "/Users,group") objUser.SetPassword "mj679s" objUser.SetInfo objGroup.Add(objUser.ADsPath) I can't seem to figure out how to apply any of the autoit scripts offered in the post mentioned above to solve this problem. What is the layout of the file ? can you show few records ? Edited February 7, 2006 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...
mrrlg Posted February 7, 2006 Author Share Posted February 7, 2006 It is by first name, last name, log on name, password and description, which is a way of identifying what group each user belongs to. First Name,Last Name,Login Name,Password,Description Aldo,Fernandez,afernandez,america9,SCB Alejandro,Arias,aarias,311212ab,SCB Angel,Vieyra,avieyra,colceacini,SCB Anita,Ibarra,aibarra,sbptiw,SCB Carlos,Pazariz,cpazariz,mfmymc,SCB Celia,Smith,csmith,yspgxh,SCB Edith,Valenzuela,evalenzuela,edithvale,SCB Link to comment Share on other sites More sharing options...
Developers Jos Posted February 7, 2006 Developers Share Posted February 7, 2006 (edited) Here's a start to get you going... expandcollapse popup$file = FileOpen("users.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read the titkeline $line = FileReadLine($file) If @error = -1 Then Exit ; Init objects $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 While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ; Split record on comma: First Name,Last Name,Login Name,Password,Description $Userinfo = StringSplit($line,",") $objUser = $colAccounts.Create("user", $Userinfo[3]) $objUser.SetPassword ($Userinfo[4]) $objUser.SetInfo $objGroup.Add($objUser.ADsPath) Wend FileClose($file) ; ; ; 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 & _ "Windescription is: " & $oMyError.windescription ) SetError(1); something to check for when this function returns Endfunc Edited February 7, 2006 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...
mrrlg Posted February 8, 2006 Author Share Posted February 8, 2006 I am using your suggestion and am getting the error "unknown function name" at ObjEvent in this line of code. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler I am using AutoIt version 3.1.1 and there is no reference to ObjEvent in the help file. Is this part of the beta version of AutoIt? Link to comment Share on other sites More sharing options...
seandisanti Posted February 8, 2006 Share Posted February 8, 2006 I am using your suggestion and am getting the error "unknown function name" at ObjEvent in this line of code. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler I am using AutoIt version 3.1.1 and there is no reference to ObjEvent in the help file. Is this part of the beta version of AutoIt?beta is required Link to comment Share on other sites More sharing options...
mrrlg Posted February 8, 2006 Author Share Posted February 8, 2006 Thank you both, it worked perfectly with the beta version! Now if I could impose upon you for two more things. How do I get the first and last name inserted as full name and the description added when the user account is created? Link to comment Share on other sites More sharing options...
Developers Jos Posted February 8, 2006 Developers Share Posted February 8, 2006 Thank you both, it worked perfectly with the beta version! Now if I could impose upon you for two more things. How do I get the first and last name inserted as full name and the description added when the user account is created?come on... you have the basics running so just a bit of research should give you the info needed.... 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...
SPTech Posted February 9, 2006 Share Posted February 9, 2006 Thank you both, it worked perfectly with the beta version! Now if I could impose upon you for two more things. How do I get the first and last name inserted as full name and the description added when the user account is created?To go just a little bit further than JdeB, you need to take a look at $objUser.FullName and $objUser.Description.... Fully automatic, comes in any sizeMakes me wonder what I did before I got synchronized... 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