Create User with VB Script
[ad#ad-4]
This is a sample working code to create users in bulk by reading a text file
containing list of users (each line of text file contain name of a user):
It requires text file as command line argument.
‘———-
strComputer = “.” ‘local computer
set objArgs = wscript.arguments
if objArgs.count <> 1 then
wscript.echo “Usage: ” & wscript.scriptFullName & ”
<text_file_containing_user_names>”
wscript.quit
end if
strServerListFile=objArgs(0)
set fs = CreateObject(“Scripting.FileSystemObject”)
if NOT fs.fileExists(strServerListFile) then
wscript.echo “Text file containing User list not found.”
wscript.quit
end if
set fl = fs.openTextFile(strServerListFile)
while not fl.atEndOfStream
strUser=fl.readLine
wscript.echo strUser
’strUser contain the name of user read from text file.
‘Create user account and assign values for different properties here ‘——————————————————————————-
Set colAccounts = GetObject(“WinNT://” & strComputer & “”)
Set objUser = colAccounts.Create(“user”,strUser)
objUser.SetPassword “09iu%4et”
objUser.SetInfo ‘needed to save property values for user.
‘Add other user properties here: ‘——————————————————————————-
‘End creating user account
wend
fl.close
[ad#ad-4]
====== for more scripting you can learn it from Microsoft Microsoft Script Center
No related posts.




Recent Comments