i = 0
Const ForReading = 1
strInputFile="C:\BAU_Users.txt" '需要建立用户账户所在的文件
Set FSO=CreateObject("Scripting.FileSystemObject")
Set objFile=FSO.OpenTextFile(strInputFile,ForReading)
strComputer = objNetwork.ComputerName '得到本地计算机名
colAccounts.Filter = Array("group") '提取本地组信息
If objGroup.Name = pcAnywhere_users Then
intExists = 2
End If
Next
objGroup.SetInfo
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
strAccount =arrFileLines(n)
strPswd = "viso1234" '并为每个新建用户创建初始密码"viso1234"
intExists = 0
For Each objUser In colAccounts
If objUser.Name = strAccount Then
intExists = 1
End If
Next
Set objUser = colAccounts.Create("user", strAccount)
objUser.SetPassword strPswd
objUser.SetInfo
objUser.PasswordExpired = 1 '新建的账户必须在首次登录时需重设密码
objUser.SetInfo
Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",user")
objGroup.Add(objUser.ADsPath) '将新建账户加入本地管理员组中
Set objGroup = GetObject("WinNT://" & strComputer & "/pcAnywhere_users,group")
Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",user")
objGroup.Add(objUser.ADsPath) '将新建账户加入pcAnywhere_users组中
else
Set objUser = colAccounts.Create("user", strAccount)
objUser.SetPassword strPswd
objUser.SetInfo
objUser.PasswordExpired = 1
objUser.SetInfo '从第9行开始,只要本地不存在的账户都一一建立
Set objGroup = GetObject("WinNT://" & strComputer & "/pcAnywhere_users,group")
Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",user")
objGroup.Add(objUser.ADsPath)
End If
Next