Help with VBS!

Oct 19, 2006
194
1
81
First of all I am not very good at writing programing or scripts, this is the first time i've ever tried to use a VB script.

I found this script on the web, for creating user home directories en mass and setting directory permissions. The script is supposed to pull the names for the folders from an excel file which I have created. I don't have VB installed on my machine, i'm just using wordpad. The error i get is on line 17 "sHomeDir = sHome&sUser". It tells me i have an "expected statement". whatever that means I have looked around and suposedly it means I have something missing but I have no clue. Any help would be a life saver! thanks!


Dim oFSO, oExcel, oSheet, sUser, iRow
iRow = 2
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oExcel = CreateObject("Excel.Application")
Set oSheet = oExcel.Workbooks.Open("C:\download\scriptsusernames.xls")

Do Until oExcel.Cells(iRow,1).Value= ""
sUser=oExcel.Cells(iRow,1).Value
iRow = iRow+1
Call HomeDir()
Loop
oExcel.Quit

Wscript.Quit

Sub HomeDir()
sHome = C:\download
sHomeDir = sHome&sUser
If oFSO.FolderExists(sHomeDir) Then
Set oFolder = oFSO.GetFolder(sHomeDir)
WScript.Echo sHomeDir&"'s home directory already exists."
Else
oFSO.CreateFolder(sHomeDir)
Set oShell = Wscript.CreateObject(Wscript.Shell)
oShell.Run "%COMSPEC% /c cacls Echo Y| "& sHomeDir & " /t /c /g Administrators:F "& sUser & ":F", 2, True
End If
End Sub


 

Cerebus451

Golden Member
Nov 30, 2000
1,425
0
76
Don't really know VB script at all, but just taking a guess do you need to enclose the C:\download on the previous line in quotes since it is a string?
 

KLin

Lifer
Feb 29, 2000
30,950
1,076
126
Got it to work with some changes. Replace [DOMAIN] with an active directory domain to give a domain account permissions. Works slick. :thumbsup:

EDIT: make sure the users start in row 2 in the excel spreadsheet too.
 
Oct 19, 2006
194
1
81
Originally posted by: KLin
Got it to work with some changes. Replace [DOMAIN] with an active directory domain to give a domain account permissions. Works slick. :thumbsup:

EDIT: make sure the users start in row 2 in the excel spreadsheet too.


Thank you so much! I would have never been able to figure it out by myself. I hope more people can use this to help in such a repetitive task.