我的VBS有问题

时间:2010-12-09 11:27:49

标签: windows-server-2003 vbscript

我正在尝试从xls文件添加用户列表,我收到此错误:

Line: 6
Char: 5
Invalid Syntax

我尝试使用的脚本如下所示:

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
    ("C:\Scriptt/Users.xls")
intRow = 3
Do Until objExcel.Cells(intRow,1).Value = ""
    Set objOU = GetObject("ou=REAL, dc=ormbunken, dc=com")
    Set objUser = objOU.Create _
        ("User", "cn=" & objExcel.Cells(intRow, 2).Value)
    objUser.sAMAccountName = objExcel.Cells(intRow, 1).Value
    objUser.SetPassword = objExcel.Cells(intRow, 5).Value
    objUser.GivenName = objExcel.Cells(intRow, 3).Value
    objUser.SN = objExcel.Cells(intRow, 4).Value
    objUser.AccountDisabled = FALSE
    objUser.SetInfo
    intRow = intRow + 1
Loop
objExcel.Quit

有谁知道什么是错的?

1 个答案:

答案 0 :(得分:1)

您是否需要在GetObject电话中提供协议/服务器?就像这说的那样

Set oOU = GetObject("LDAP://test.test.cz/ou=skup,dc=test,dc=test,dc=cz")
Set oUser = oOU.Create("User", "cn=" & "Test" & " " & "Tester")

取自http://msdn.itags.org/iis/2649/


做了一个谷歌,发现了http://www.computerperformance.co.uk/vbscript/vbscript_user_spreadsheet.htm

相关问题