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