Question

Locked

VBS Scripts running on Server 2008

By scott_langshaw2 ·
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

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Could be the CSV file itself

by Brenton Keegan In reply to VBS Scripts running on Se ...

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.

Collapse -

2008

by scott_langshaw2 In reply to Could be the CSV file its ...

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

Are you testing the script on 2008 server?

Thanks for your reply

Collapse -

Another quick edition

by scott_langshaw2 In reply to 2008

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

Collapse -

Sorry...

by Brenton Keegan In reply to Another quick edition

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.

Collapse -

No worries

by scott_langshaw2 In reply to Sorry...

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

Collapse -

Looks like a 2008 issue

by neilb@uk In reply to VBS Scripts running on Se ...

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 :)

Back to Networks Forum
6 total posts (Page 1 of 1)  

Related Forums