Jump to content

Recommended Posts

Posted

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!

Posted

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

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...