Question Locked

VBS Scripts running on Server 2008

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi All

i am installing a new windows server 2008 server in a school this summer and i am having a problem with the scripts i wrote for windows server 2003 working on 2008.

The script is addding users to AD through a csv file, creating the home directory as well as other things. When i run the script it comes up with the following error

Error - Syntax error in FROM clause
Code - 80040E14
Source - Microsoft Jet Engine Database
Line 17
Char 1

If anyone could help i would be much appreciated.

Here is the script below

Dim sCSVFileLocation, sCSVFile, oConnection, oRecordSet, oNewUser, oRootLDAP, oContainer, sLogon, sFirstName, sLastName
Dim sDisplayName, sPassword, nPwdLastSet, nUserAccountControl, sDomain, HomeDriveServerPath, HomeDriveLetter, objFSO
Dim objFolder, oshell

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = wscript.CreateObject("Wscript.Shell")
sDomain ="swdomain.local"

sCSVFileLocation = "C:\scripts\"
sCSVFile = sCSVFileLocation&"year5.csv"

set oConnection = createobject("adodb.connection")
set oRecordSet = createobject("adodb.recordset")
oConnection.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & sCSVFileLocation & ";Extended Properties=""text;HDR=NO;FMT=Delimited"""
oRecordSet.open "SELECT * FROM " & sCSVFile ,oConnection

Set oRootLDAP = GetObject("LDAP://rootDSE")
Set oContainer = GetObject("LDAP://cn=Users," & _
oRootLDAP.Get("defaultNamingContext"))

do until oRecordSet.EOF

sLogon = oRecordSet.Fields.Item(0).value
sFirstName = oRecordSet.Fields.Item(1).value
sLastName = oRecordSet.Fields.Item(2).value
sDisplayName = sLastName&", "&sFirstName
sPassword = oRecordSet.Fields.Item(3).value

HomeDriveServerPath = "\\swserver\homes\" & sLogon
HomeDriveLetter = "U:"
scriptPath = "students.bat"

Set objFolder = objFSO.CreateFolder("\\swserver\homes\" & sLogon)

Set oNewUser = oContainer.Create("User","cn="&sFirstName&" "&SLastName)

oNewUser.put "sAMAccountName",lcase(sLogon)
oNewUser.put "givenName",sFirstName
oNewUser.put "sn",sLastName
oNewUser.put "UserPrincipalName",lcase(SLogon)&"@"&sDomain
oNewUser.put "DisplayName",sDisplayName
oNewUser.put "name",lcase(sLogon)

oNewUser.SetInfo

oNewUser.SetPassword sPassword
oNewUser.Put "pwdLastSet", 0
oNewUser.Put "homeDrive", HomeDriveLetter
oNewUser.SetInfo
oNewUser.Put "homeDirectory", HomeDriveServerPath
oNewUser.SetInfo
oNewUser.Put "scriptPath", scriptPath
oNewUser.Setinfo

oNewUser.Put "userAccountControl", 512
oNewUser.Put "userAccountControl", 66048
oNewUser.SetInfo

oShell.Run "%COMSPEC% /c Echo Y| cacls \\swserver\homes\" & sLogon & " /t /e /g Administrators:F "& Slogon & ":F", 2, True

oRecordset.MoveNext

Loop

7 replies

by brenton keegan

I did some googling and I found this:
http://www.adopenstatic.com/faq/80040e14.asp

This explains some particulars that might cause the error you are getting.

Since the error referred to line 17 which was your query execution I tested the connection string and execution on a dummy csv file I set up. I did not get any errors.

by scott_langshaw2

Thanks for the infomation i will have a look at it :).

Are you testing the script on 2008 server?

Thanks for your reply

by scott_langshaw2

I have just tested the following script on server 2003 and it worked perfectly with the csv file i have but when i run the same script with 2008 with the same csv it comes up with the error in the first post.

Any help urgently need by 2moro.

Thanks all

by brenton keegan

Sorry, I don't have a Win2k8 box and doing several google searches didn't yield anything useful. I cannot help you on this one.

Good luck.

by scott_langshaw2

No worries mate thanks for your help anyway i will figure it out in the end i hope lol

by Member 25348569

I can't test it as my 2008 servers just moan that the provider isn't installed. As I use PowerShell these days, I'm not going to do that.

Why not just use a simpler strategy to load and parse your csv file? Read in each line in your csv and split() into an array - assuming that you have no commas in the data fields!

Neil :)

This discussion is closed to new replies.