w00blyn Posted April 27, 2009 Posted April 27, 2009 Hello I'm trying to make a script to add users during my winxp unattended install. Inside the $OEM$ there's a userinfo.ini file which looks something like this: CODE[user1] username=Me! password=**** group=Administrators autologon=True [user2] username=Somebody Else password=**** group=Users autologon=False In my script, I'm trying to generate variables according to how many users are entered in the ini. This part is tricking me: CODE$entries = IniReadSectionNames ($ini) For $e = 1 to $entries[0] $usr & $e = IniRead ($ini, "User " & $e, "username", "") msgbox (1, "bah", $usr) Next My plan is to read the section names, and for each 'user1', 'user2' section, create corresponding variables $usr1, $usr2. I can't figure out how to use the array number ($e) inside my variable name. I'm sure the solution is simple, it always seems to be in after thought.. Thanks!
w00blyn Posted April 27, 2009 Author Posted April 27, 2009 Yup, simple solution. Muaha. CODE$entries = IniReadSectionNames ($ini) For $e = 1 to $entries[0] $usr = IniRead ($ini, "User" & $e, "username", "") $pwd = IniRead ($ini, "User" & $e, "password", "") $grp = IniRead ($ini, "User" & $e, "group", "Users") $aut = IniRead ($ini, "User" & $e, "autologon", "False") AddUser ($usr, $pwd, $grp, $aut) Next Func AddUser ($user, $pass, $group, $auto) RunWait(@Comspec & " /c net user " & $user & " " & $pass & " /add") RunWait(@Comspec & " /c net localgroup " & $group & " " & $user & " /add") RunWait(@Comspec & " /c net accounts /maxpwage:unlimited") If $auto = True Then RegWrite ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName","REG_SZ", $user) RegWrite ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword","REG_SZ", $pass) RegWrite ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon","REG_SZ", "1") EndIf EndFunc
WideBoyDixon Posted April 27, 2009 Posted April 27, 2009 Much better coding style of course. However, going back to your original question I think what you were looking for is: Assign("$usr" & $e, IniRead($ini, "User" & $e, "username", "") WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
w00blyn Posted April 27, 2009 Author Posted April 27, 2009 Cool! Thanks man, didn't know about that function. Neat.
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