This is a multi-part message in MIME format.

------=_NextPart_000_002F_01C3DE82.D66A20A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Scripting Guys !!!!

So, my script read a file text where is a list of users what must be =
create, this create de user and register this action on Excell File, the =
scritp of create users if it is running on a separate mode it=B4s run =
perfect, when I use it on the middle of process I=B4d receive this error =
code:
"A device attached to the system is not functioning "
Error Code : 8007001F
Line 49: --> objUser.SetInfo
Please Help Me !"

Kind Regards

Rafael Brum Astrana

Text File Format:
---------------------------------------------------------------------
"User1","My name is 1", "passw1"
"User2","My name is 2", "passw2"
"User3","My name is 3", "passw3"
"User4","My name is 4", "passw4"

This is the script:=20
----------------------------------------------------
x=3D0
Const ForReading =3D 1
Const ForAppending =3D 8
Const ADS_PROPERTY_APPEND =3D 3
Row =3D 2
Set XL =3D WScript.CreateObject("Excel.Application")
Set objFSO =3D CreateObject("Scripting.FileSystemObject")
Set objTextFile =3D objFSO.OpenTextFile _
(".\arquivo.txt", ForReading)
Call CreateTable()
Do Until objTextFile.AtEndOfStream
Call Process()
Loop
' ---------------------------------------------
Function Process()
strNextLine =3D objTextFile.Readline
arrServiceList =3D Split(strNextLine , ",")
username =3D arrServiceList(0)
For i =3D 1 To Ubound(arrServiceList)
If X =3D 0 Then
name =3D arrServiceList(i)
X =3D 1
Else
Passw =3D arrServiceList(i)
X =3D 0
End If
Next
Call CreateUser(username, name, passw)
End Function

Sub CreateUser(username, name, passw)
strUserName =3D username=20
Set objConnection =3D CreateObject("ADODB.Connection")
objConnection.Open "Provider=3DADsDSOObject;"
Set objCommand =3D CreateObject("ADODB.Command")
objCommand.ActiveConnection =3D objConnection
objCommand.CommandText =3D _=20
=
"<LDAP://portoalegre.pucrsnet.br/dc=3Dportoalegre,dc=3Dpucrsnet,dc=3Dbr>;=
(&(objectCategory=3DUser)" & _
"(samAccountName=3D" & strUserName & =
"));samAccountName,distinguishedName;subtree"
: Set objRecordSet =3D objCommand.Execute
If objRecordset.RecordCount =3D 0 Then
objConnection.Close=20
Set objOU =3D =
GetObject(LDAP://ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,d=
c=3DMyHolder1)
Set objUser =3D objOU.Create("User", "cn=3D" & username)
objUser.Put "sAMAccountName", username
objUser.Put "userPrincipalName", username & =
"@MyChildDomain.MyHolder.MyHolder1"
objUser.SetInfo
Set objUser =3D GetObject ("LDAP://cn=3D" & username & =
",ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,dc=3DMyHolder1")=

objUser.AccountDisabled =3D False
objuser.displayName =3D Trim(name)
objUser.SetPassword passw
objUser.Put "pwdLastSet", 0
objuser.description =3D "HR"
objuser.HomeDrive =3D "H"
objuser.HomeDirectory =3D "\\MyFileServer\" & username & "$"
objuser.scriptpath =3D "S_H.bat"
objUser.SetInfo
Call Register(username, name, passwd)
End If
End Sub

Function CreateTable()
XL.Visible =3D True
Set Book =3D XL.WorkBooks.Add
XL.Columns(1).ColumnWidth =3D 20
XL.Columns(2).ColumnWidth =3D 20
XL.Cells(1, 1).Value =3D "Username"
XL.Cells(1, 2).Value =3D "Nome"
XL.Cells(1, 3).Value =3D "Senha"
XL.Range("A1:C1").Select
XL.Selection.Font.Bold =3D True
XL.Selection.Font.Italic =3D True
XL.Selection.Font.Size =3D 18
End Function=20

Sub Saveas()
TheDate =3D Date
TheDate =3D Replace(TheDate, "/", "-")
Suggestion =3D "Usu=E1rios Criados " & TheDate & ".xls"
FileName =3D XL.GetSaveasFilename(Suggestion)
If FileName <> False Then
Book.SaveAs(FileName)
End If
End Sub

Sub Registro(Username, Nome, senha)
XL.Cells(Row, 1).Value =3D Username
XL.Cells(Row, 2).Value =3D Name
XL.Cells(Row, 3).Value =3D Passw
Row =3D Row + 1
XL.Cells(Row, 1).Select
End Sub=20

call Saveas()
Wscript.echo "See Ya At next user=B4s List"
------=_NextPart_000_002F_01C3DE82.D66A20A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi Scripting Guys !!!!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So, my script read a file text where is =
a list of=20
users what must be create, this create de user and register this action =
on=20
Excell File, the scritp of create users if it is running on a separate =
mode it=B4s=20
run perfect, when I use it on the middle of process I=B4d receive this =
error=20
code:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"A device attached to the system is not =
functioning=20
"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Error Code : 8007001F</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Line 49: --&gt; =
objUser.SetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Please Help Me !"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Kind Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Rafael Brum Astrana</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Text File Format:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
-----</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"User1","My name is 1", =
"passw1"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"User2","My name is 2", =
"passw2"</FONT></DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>"User3","My name is 3", =
"passw3"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"User4","My name is 4", =
"passw4"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This is the script: </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------</FONT></DIV=
></DIV>
<DIV><FONT face=3DArial size=3D2>x=3D0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Const ForReading =3D 1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Const ForAppending =3D 8</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Const ADS_PROPERTY_APPEND =3D =
3</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Row =3D 2</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Set XL =3D=20
WScript.CreateObject("Excel.Application")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Set objFSO =3D=20
CreateObject("Scripting.FileSystemObject")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Set objTextFile =3D objFSO.OpenTextFile =

_</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>(".\arquivo.txt", =
ForReading)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Call CreateTable()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Do Until =
objTextFile.AtEndOfStream</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Call =
Process()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Loop</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>'=20
---------------------------------------------</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Function Process()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; strNextLine =3D=20
objTextFile.Readline</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; arrServiceList =3D =
Split(strNextLine ,=20
",")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; username =3D=20
arrServiceList(0)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; For i =3D 1 To=20
Ubound(arrServiceList)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If =
X =3D 0=20
Then</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
name =3D=20
arrServiceList(i)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X =
=3D=20
1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;Else</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Passw =3D=20
arrServiceList(i)</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X =3D=20
0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; End If</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Next</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Call =
CreateUser(username, name,=20
passw)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Function</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sub CreateUser(username, name, =
passw)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;strUserName =3D =
username=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objConnection =
=3D=20
CreateObject("ADODB.Connection")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objConnection.Open=20
"Provider=3DADsDSOObject;"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objCommand =3D=20
CreateObject("ADODB.Command")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objCommand.ActiveConnection =3D=20
objConnection</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objCommand.CommandText =3D _=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
"&lt;LDAP://portoalegre.pucrsnet.br/dc=3Dportoalegre,dc=3Dpucrsnet,dc=3Db=
r&gt;;(&amp;(objectCategory=3DUser)"=20
&amp; _</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; "(samAccountName=3D" =
&amp;=20
strUserName &amp; =
"));samAccountName,distinguishedName;subtree"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; : Set objRecordSet =
=3D=20
objCommand.Execute</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;If objRecordset.RecordCount =
=3D 0=20
Then</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objConnection.Close=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objOU =3D =
GetObject(<A=20
href=3D"ldap://ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,dc=3D=
MyHolder1">LDAP://ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,=
dc=3DMyHolder1</A>)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objUser =3D=20
objOU.Create("User", "cn=3D" &amp; username)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objUser.Put =
"sAMAccountName",=20
username</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objUser.Put =
"userPrincipalName",=20
username &amp; "@<U><FONT=20
color=3D#0000ff>MyChildDomain.MyHolder.MyHolder1</FONT></U>"</FONT></DIV>=

<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objUser.SetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objUser =3D =
GetObject=20
("LDAP://cn=3D" &amp; username &amp; ",<U><FONT=20
color=3D#0000ff>ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,dc=
=3DMyHolder1</FONT></U>")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objUser.AccountDisabled =3D=20
False</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objuser.displayName =
=3D=20
Trim(name)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objUser.SetPassword=20
passw</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objUser.Put =
"pwdLastSet",=20
0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objuser.description =
=3D=20
"HR"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objuser.HomeDrive =
=3D=20
"H"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objuser.HomeDirectory =3D=20
"\\MyFileServer\" &amp; username &amp; "$"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objuser.scriptpath =
=3D=20
"S_H.bat"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objUser.SetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Call =
Register(username, name,=20
passwd)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; End If</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Sub</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Function CreateTable()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; XL.Visible =3D =
True</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Set Book =3D=20
XL.WorkBooks.Add</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Columns(1).ColumnWidth =
=3D=20
20</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Columns(2).ColumnWidth =
=3D=20
20</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; XL.Cells(1, 1).Value =
=3D=20
"Username"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Cells(1, 2).Value =3D=20
"Nome"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; XL.Cells(1, 3).Value =
=3D=20
"Senha"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; =
XL.Range("A1:C1").Select</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Selection.Font.Bold =3D =

True</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Selection.Font.Italic =
=3D=20
True</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Selection.Font.Size =3D =

18</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Function </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sub Saveas()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; TheDate =3D =
Date</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; TheDate =3D =
Replace(TheDate, "/",=20
"-")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Suggestion =3D =
"Usu=E1rios Criados "=20
&amp; TheDate &amp; ".xls"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; FileName =3D=20
XL.GetSaveasFilename(Suggestion)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; If FileName &lt;&gt; =
False=20
Then</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Book.SaveAs(FileName)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; End If</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Sub</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sub Registro(Username, Nome, =
senha)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; &nbsp;XL.Cells(Row, 1).Value =3D =

Username</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Cells(Row, 2).Value =3D =

Name</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Cells(Row, 3).Value =3D =

Passw</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Row =3D Row + =
1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Cells(Row, =
1).Select</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Sub </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>call Saveas()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Wscript.echo "See Ya At =
next&nbsp;user=B4s List"=20
</FONT></DIV></BODY></HTML>

------=_NextPart_000_002F_01C3DE82.D66A20A0--

Re: Create Users ! by Richard

Richard
Mon Jan 19 16:40:21 CST 2004

This is a multi-part message in MIME format.

------=_NextPart_000_0016_01C3DEAA.EE094F60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

I don't know what you mean by "separate mode" and "middle of process", =
but I suspect a permissions problem. If the code works in some =
situations, but not others, and the error is raised on the first =
SetInfo, it sounds like you have read permission, but not write =
permission. Since the code has already established that username is =
unique, there is no other reason for an error at that point. You may =
have anonymous access.

A few other points, just in case:

1. There seems to be a symbol (perhaps a colon) in front of the =
statement "Set objRecordSet =3D objCommand.Execute". There should not =
be.
2. I believe the homeDrive attribute should include the colon (:), as in =
"H:".
3. I did not know you could call a function, but after testing, I guess =
you can.
4. You call sub Register, but define sub Registro.
5. The parameters "Nome" and "senha" in the definition of sub Register =
(or Registro) should probably be "Name" and "Passw". Otherwise, the =
variables Name and Passw will be undefined.
6. The variable "Row" in sub Register does not have global scope. The =
value will be zero (or undefined) every time the sub is called.
7. You bind to objOU repeatedly for every user created. You can place =
the bind statement outside the loop and bind just once, since all user =
objects are created in the same OU.
8. There is no need to bind to objUser a second time after the user =
object is created. The first reference to objUser is still valid. You =
can omit the "Set objUser =3D GetObject..." statement.

I really don't see a need for the functions and subroutines. There would =
be less problems with scope and variable definitions if it was all in =
one program, without subs or functions.

I hope I haven't confused the issue.

--=20
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--

"Rafael Brum Astrana" <rastrana@pucrs.br> wrote in message =
news:%23G2s8Op3DHA.2460@TK2MSFTNGP10.phx.gbl...
Hi Scripting Guys !!!!

So, my script read a file text where is a list of users what must be =
create, this create de user and register this action on Excell File, the =
scritp of create users if it is running on a separate mode it=B4s run =
perfect, when I use it on the middle of process I=B4d receive this error =
code:
"A device attached to the system is not functioning "
Error Code : 8007001F
Line 49: --> objUser.SetInfo
Please Help Me !"

Kind Regards

Rafael Brum Astrana

Text File Format:
---------------------------------------------------------------------
"User1","My name is 1", "passw1"
"User2","My name is 2", "passw2"
"User3","My name is 3", "passw3"
"User4","My name is 4", "passw4"

This is the script:=20
----------------------------------------------------
x=3D0
Const ForReading =3D 1
Const ForAppending =3D 8
Const ADS_PROPERTY_APPEND =3D 3
Row =3D 2
Set XL =3D WScript.CreateObject("Excel.Application")
Set objFSO =3D CreateObject("Scripting.FileSystemObject")
Set objTextFile =3D objFSO.OpenTextFile _
(".\arquivo.txt", ForReading)
Call CreateTable()
Do Until objTextFile.AtEndOfStream
Call Process()
Loop
' ---------------------------------------------
Function Process()
strNextLine =3D objTextFile.Readline
arrServiceList =3D Split(strNextLine , ",")
username =3D arrServiceList(0)
For i =3D 1 To Ubound(arrServiceList)
If X =3D 0 Then
name =3D arrServiceList(i)
X =3D 1
Else
Passw =3D arrServiceList(i)
X =3D 0
End If
Next
Call CreateUser(username, name, passw)
End Function

Sub CreateUser(username, name, passw)
strUserName =3D username=20
Set objConnection =3D CreateObject("ADODB.Connection")
objConnection.Open "Provider=3DADsDSOObject;"
Set objCommand =3D CreateObject("ADODB.Command")
objCommand.ActiveConnection =3D objConnection
objCommand.CommandText =3D _=20
=
"<LDAP://portoalegre.pucrsnet.br/dc=3Dportoalegre,dc=3Dpucrsnet,dc=3Dbr>;=
(&(objectCategory=3DUser)" & _
"(samAccountName=3D" & strUserName & =
"));samAccountName,distinguishedName;subtree"
: Set objRecordSet =3D objCommand.Execute
If objRecordset.RecordCount =3D 0 Then
objConnection.Close=20
Set objOU =3D =
GetObject(LDAP://ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,d=
c=3DMyHolder1)
Set objUser =3D objOU.Create("User", "cn=3D" & username)
objUser.Put "sAMAccountName", username
objUser.Put "userPrincipalName", username & =
"@MyChildDomain.MyHolder.MyHolder1"
objUser.SetInfo
Set objUser =3D GetObject ("LDAP://cn=3D" & username & =
",ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,dc=3DMyHolder1")=

objUser.AccountDisabled =3D False
objuser.displayName =3D Trim(name)
objUser.SetPassword passw
objUser.Put "pwdLastSet", 0
objuser.description =3D "HR"
objuser.HomeDrive =3D "H"
objuser.HomeDirectory =3D "\\MyFileServer\" & username & "$"
objuser.scriptpath =3D "S_H.bat"
objUser.SetInfo
Call Register(username, name, passwd)
End If
End Sub

Function CreateTable()
XL.Visible =3D True
Set Book =3D XL.WorkBooks.Add
XL.Columns(1).ColumnWidth =3D 20
XL.Columns(2).ColumnWidth =3D 20
XL.Cells(1, 1).Value =3D "Username"
XL.Cells(1, 2).Value =3D "Nome"
XL.Cells(1, 3).Value =3D "Senha"
XL.Range("A1:C1").Select
XL.Selection.Font.Bold =3D True
XL.Selection.Font.Italic =3D True
XL.Selection.Font.Size =3D 18
End Function=20

Sub Saveas()
TheDate =3D Date
TheDate =3D Replace(TheDate, "/", "-")
Suggestion =3D "Usu=E1rios Criados " & TheDate & ".xls"
FileName =3D XL.GetSaveasFilename(Suggestion)
If FileName <> False Then
Book.SaveAs(FileName)
End If
End Sub

Sub Registro(Username, Nome, senha)
XL.Cells(Row, 1).Value =3D Username
XL.Cells(Row, 2).Value =3D Name
XL.Cells(Row, 3).Value =3D Passw
Row =3D Row + 1
XL.Cells(Row, 1).Select
End Sub=20

call Saveas()
Wscript.echo "See Ya At next user=B4s List"
------=_NextPart_000_0016_01C3DEAA.EE094F60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I don't know what you mean by "separate mode" and =
"middle of=20
process", but I suspect a permissions problem. If the code works in some =

situations, but not others, and the error is raised on the first =
SetInfo, it=20
sounds like you have read permission, but not write permission. Since =
the code=20
has already established that username is unique, there is no other =
reason for an=20
error at that point. You may have anonymous access.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>A few other points, just in case:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>1. There seems to be a symbol (perhaps a colon) in =
front of=20
the statement "Set objRecordSet =3D objCommand.Execute". There should =
not=20
be.</FONT></DIV>
<DIV><FONT size=3D2>2. I believe the homeDrive attribute should include =
the colon=20
(:), as in "H:".</FONT></DIV>
<DIV><FONT size=3D2>3. I did not know you could call a function, but =
after=20
testing, I guess you can.</FONT></DIV>
<DIV><FONT size=3D2>4. You call sub Register, but define sub=20
Registro.</FONT></DIV>
<DIV><FONT size=3D2>5. The parameters "Nome" and "senha" in the =
definition of sub=20
Register (or Registro) should probably be "Name" and "Passw". Otherwise, =
the=20
variables Name and Passw will be undefined.</FONT></DIV>
<DIV><FONT size=3D2>6. The variable "Row" in sub Register does not have =
global=20
scope. The value will be zero (or undefined) every time the sub is=20
called.</FONT></DIV>
<DIV><FONT size=3D2>7. You bind to objOU repeatedly for every user =
created. You=20
can place the bind statement outside the loop and bind just once, since =
all user=20
objects are created in the same OU.</FONT></DIV>
<DIV><FONT size=3D2>8. There is no need to bind to objUser a second time =
after the=20
user object is created. The first reference to objUser is still valid. =
You can=20
omit the "Set objUser =3D GetObject..." statement.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I really don't see a need for the functions and =
subroutines.=20
There would be less problems with scope and variable definitions if it =
was all=20
in one program, without subs or functions.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I hope I haven't confused the issue.</FONT></DIV>
<DIV><FONT size=3D2><BR>-- <BR>Richard<BR>Microsoft MVP Scripting and=20
ADSI<BR>HilltopLab web site - <A=20
href=3D"http://www.rlmueller.net">http://www.rlmueller.net</A><BR>--</FON=
T></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Rafael Brum Astrana" &lt;<A=20
href=3D"mailto:rastrana@pucrs.br">rastrana@pucrs.br</A>&gt; wrote in =
message <A=20
=
href=3D"news:%23G2s8Op3DHA.2460@TK2MSFTNGP10.phx.gbl">news:%23G2s8Op3DHA.=
2460@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Hi Scripting Guys !!!!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So, my script read a file text where =
is a list of=20
users what must be create, this create de user and register this =
action on=20
Excell File, the scritp of create users if it is running on a separate =
mode=20
it=B4s run perfect, when I use it on the middle of process I=B4d =
receive this=20
error code:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"A device attached to the system is =
not=20
functioning "</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Error Code : 8007001F</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Line 49: --&gt; =
objUser.SetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Please Help Me !"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Kind Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Rafael Brum Astrana</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Text File Format:</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2>----------------------------------------------------------------=
-----</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"User1","My name is 1", =
"passw1"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"User2","My name is 2", =
"passw2"</FONT></DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>"User3","My name is 3", =
"passw3"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"User4","My name is 4", =
"passw4"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This is the script: </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2>----------------------------------------------------</FONT></DIV=
></DIV>
<DIV><FONT face=3DArial size=3D2>x=3D0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Const ForReading =3D 1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Const ForAppending =3D 8</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Const ADS_PROPERTY_APPEND =3D =
3</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Row =3D 2</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Set XL =3D=20
WScript.CreateObject("Excel.Application")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Set objFSO =3D=20
CreateObject("Scripting.FileSystemObject")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Set objTextFile =3D =
objFSO.OpenTextFile=20
_</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>(".\arquivo.txt", =
ForReading)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Call CreateTable()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Do Until =
objTextFile.AtEndOfStream</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Call =
Process()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Loop</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>'=20
---------------------------------------------</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Function Process()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; strNextLine =3D=20
objTextFile.Readline</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; arrServiceList =3D =
Split(strNextLine ,=20
",")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; username =3D=20
arrServiceList(0)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; For i =3D 1 To=20
Ubound(arrServiceList)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
If X =3D 0=20
Then</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
name =3D=20
arrServiceList(i)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
X =3D=20
1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;Else</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Passw =3D=20
arrServiceList(i)</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X =3D=20
0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; End =
If</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Next</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Call =
CreateUser(username,=20
name, passw)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Function</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sub CreateUser(username, name,=20
passw)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;strUserName =
=3D username=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objConnection =
=3D=20
CreateObject("ADODB.Connection")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objConnection.Open =

"Provider=3DADsDSOObject;"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objCommand =3D =

CreateObject("ADODB.Command")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objCommand.ActiveConnection =3D=20
objConnection</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objCommand.CommandText =3D _=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
=
"&lt;LDAP://portoalegre.pucrsnet.br/dc=3Dportoalegre,dc=3Dpucrsnet,dc=3Db=
r&gt;;(&amp;(objectCategory=3DUser)"=20
&amp; _</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
"(samAccountName=3D" &amp;=20
strUserName &amp; =
"));samAccountName,distinguishedName;subtree"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; : Set objRecordSet =
=3D=20
objCommand.Execute</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;If =
objRecordset.RecordCount =3D 0=20
Then</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objConnection.Close=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objOU =3D =
GetObject(<A=20
=
href=3D"ldap://ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,dc=3D=
MyHolder1">LDAP://ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,=
dc=3DMyHolder1</A>)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objUser =3D=20
objOU.Create("User", "cn=3D" &amp; username)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objUser.Put =
"sAMAccountName",=20
username</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objUser.Put=20
"userPrincipalName", username &amp; "@<U><FONT=20
=
color=3D#0000ff>MyChildDomain.MyHolder.MyHolder1</FONT></U>"</FONT></DIV>=

<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objUser.SetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Set objUser =3D =
GetObject=20
("LDAP://cn=3D" &amp; username &amp; ",<U><FONT=20
=
color=3D#0000ff>ou=3DAlunos,ou=3DAcad,dc=3DMyChildDomain,dc=3DMyHolder,dc=
=3DMyHolder1</FONT></U>")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objUser.AccountDisabled =3D=20
False</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objuser.displayName =3D=20
Trim(name)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objUser.SetPassword=20
passw</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objUser.Put =
"pwdLastSet",=20
0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objuser.description =3D=20
"HR"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objuser.HomeDrive =
=3D=20
"H"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objuser.HomeDirectory =3D=20
"\\MyFileServer\" &amp; username &amp; "$"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; objuser.scriptpath =
=3D=20
"S_H.bat"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
objUser.SetInfo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Call =
Register(username, name,=20
passwd)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; End If</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Sub</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Function CreateTable()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; XL.Visible =3D =
True</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Set Book =3D=20
XL.WorkBooks.Add</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; =
XL.Columns(1).ColumnWidth =3D=20
20</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; =
XL.Columns(2).ColumnWidth =3D=20
20</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; XL.Cells(1, =
1).Value =3D=20
"Username"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Cells(1, 2).Value =3D =

"Nome"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; XL.Cells(1, =
3).Value =3D=20
"Senha"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;=20
XL.Range("A1:C1").Select</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Selection.Font.Bold =
=3D=20
True</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Selection.Font.Italic =
=3D=20
True</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Selection.Font.Size =
=3D=20
18</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Function </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sub Saveas()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; TheDate =3D =
Date</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; TheDate =3D =
Replace(TheDate,=20
"/", "-")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Suggestion =3D =
"Usu=E1rios Criados=20
" &amp; TheDate &amp; ".xls"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; FileName =3D=20
XL.GetSaveasFilename(Suggestion)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; If FileName =
&lt;&gt; False=20
Then</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Book.SaveAs(FileName)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; End =
If</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Sub</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sub Registro(Username, Nome, =
senha)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; &nbsp;XL.Cells(Row, 1).Value =
=3D=20
Username</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Cells(Row, 2).Value =
=3D=20
Name</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Cells(Row, 3).Value =
=3D=20
Passw</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; Row =3D Row + =
1</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; XL.Cells(Row, =
1).Select</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Sub </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>call Saveas()</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Wscript.echo "See Ya At =
next&nbsp;user=B4s List"=20
</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0016_01C3DEAA.EE094F60--


Re: Create Users ! by hiribarne

hiribarne
Fri Sep 17 17:42:04 CDT 2004


Hi all,

I was also frustated with my own script to create all the new account
in my university, using adsi in vbscript over windows scripting host.

I had the same error: 8007001F in the first SetInfo, but with only on
account ...

solution ... NEVER!!! create an account using adsi putting
sAMAccountName attribute with more than 20 characters ...

it doesn't work for pre-Windows 2000 systems ... and if yours i
pre-Win ... you most take it into account.

so check your login's length ... and trunk them to 20 chars ...

and special thanks to MS for giving so "understandable" erro
descriptions.

Sorry if I C very late your comments, Good Luck anyway!

Roberto Hiribarne Guedes.

Rafael Brum Astrana Wrote:
> Hi Scripting Guys !!!!
>
> So, my script read a file text where is a list of users what must b
> create, this create de user and register this action on Excell File
> the scritp of create users if it is running on a separate mode it´s ru
> perfect, when I use it on the middle of process I´d receive this erro
> code:
> "A device attached to the system is not functioning "
> Error Code : 8007001F
> Line 49: -- objUser.SetInfo
> Please Help Me !"
>
> Kind Regards
>
> Rafael Brum Astrana


--
hiribarne