Created
November 27, 2015 16:50
-
-
Save WildGenie/24341ce5a15dc778fcbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Module Module1 | |
Sub Main() | |
' Open up the text file | |
Dim oFSO, oTS, sOU, sGrp | |
oFSO = CreateObject("Scripting.FileSystemObject") | |
oTS = oFSO.OpenTextFile("D:\batch\users.csv") | |
Const ADS_PROPERTY_APPEND = 3 | |
' create the necessary variables | |
Dim sUserID, sGivenName, sDisplayname, sSurname, sDescription, strComputer, sPassword, colAccounts, objUser, objGroup, objGroup55, sPonge, objUser2 | |
'skip the first line of the file | |
Dim sLine, sData | |
'sLine = oTS.ReadLine | |
sLine = oTS.ReadLine | |
strComputer = "." | |
colAccounts = GetObject("WinNT://" & strComputer & "") | |
' now go through the file one line at a Time | |
Do Until oTS.AtEndOfStream | |
On Error Resume Next | |
'read the line and split it on the commas | |
sLine = oTS.ReadLine | |
sData = Split(sLine, ",") | |
' get the user information from this row | |
'sPassword = sData(0) | |
sGivenName = sData(0) | |
sSurname = sData(1) | |
sPassword = sData(2) | |
sDescription = sData(3) | |
objUser = colAccounts.Create("user", sGivenName) | |
objUser.SetPassword(sPassword) | |
objUser.id = sGivenName | |
objUser.fullname = sSurname | |
objUser.SetInfo() | |
objUser = GetObject("WinNT://" & strComputer & "/" & sGivenName & ",user") | |
objGroup = GetObject("WinNT://" & strComputer & "/Пользователи удаленного рабочего стола,group") | |
objGroup.Add(objUser.ADsPath) | |
objGroup55 = GetObject("WinNT://" & strComputer & "/Пользователи,group") | |
objGroup55.Add(objUser.ADsPath) | |
objUser.description = sDescription | |
objUser.fullname = sSurname | |
objUser.TerminalServicesInitialProgram = "D:\batch\union.cmd" | |
objUser.ConnectClientDrivesAtLogon = 1 | |
objUser.DefaultToMainPrinter = 1 | |
objUser.SetInfo() | |
Loop | |
oTS.Close() | |
End Sub | |
Function SetGroups(ByVal sGivenName) | |
Dim strComputer, colAccounts, objGroup, objGroup55, objUser2 | |
strComputer = "." | |
colAccounts = GetObject("WinNT://" & strComputer & "") | |
objGroup = GetObject("WinNT://" & strComputer & "/Пользователи удаленного рабочего стола,group") | |
objGroup55 = GetObject("WinNT://" & strComputer & "/Пользователи,group") | |
objUser2 = GetObject("WinNT://" & strComputer & "/" & sGivenName.ToString & ",user") | |
objGroup.Add(objUser2.ADsPath) | |
objGroup55.Add(objUser2.ADsPath) | |
Return 0 | |
End Function | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment