Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help - need script to add users from Excel 1

Status
Not open for further replies.

mdwu

Technical User
Jul 17, 2003
98
US
Can anyone provide a script so I can add local users, not domain user from an excel spreadsheet. I have about 200 local users I need to add on to windows 2003. Many thanks.
 
I haven't used this for a while but i've used it to create multiple users from a .csv in the past, have a play on a test box i'm sure it will work.

Code:
Call Main()


Sub Main()

	Call makeUsersFromCSV("USERS.csv")

End Sub


Sub makeUsersFromCSV(strCSVFile)

	'import from csv (full name, username, pwd)
	

	Dim objFSO, objFile, arrUser, strFName, strUName, strPwd
	Const ForReading = 1

	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objFile = objFSO.OpenTextFile(strCSVFile, ForReading)

	Do While Not objFile.AtEndOfStream

		arrUser = Split(objFile.ReadLine, ",")
		strFName = arrUser(0)
		strUName = arruser(1)
		strPwd = arrUser(2)

		Call AddUser(strUName, strFName, strPwd)

	Loop

	objFile.Close

End Sub







 Sub AddUser(strUser,strFullname,strPassword)
    Dim Computer
    Dim User
     Set Computer = Getobject("WinNT://DOMAINNAME")
     Set User = computer.create("User",strUser)
    User.fullname = strFullname

   call User.SetPassword(strPassword)
   User.setinfo

   Set User = nothing
   Set computer = nothing
 End sub





When you are the IT director, it's your job to make sure the IT works. If it does work they know already and if it doesn't, they don't want to hear your pathetic excuses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top