PCBrandon
IS-IT--Management
- Jan 6, 2007
- 17
Hello,
I have a small script that pulls usernames from an excel sheet and creates a folder/sets permissions for each user. I'm getting the following error when running it:
Line: 26
Char: 110
Error: Cannot use parentheses when calling a Sub
Code: 800A0414
Source: Microsoft VBScript compilation error
The code is posted in its entirety below:
The line the error references is the oShell.Run line. The file is saved as a .vbs file.
Any thoughts? Thanks!
I have a small script that pulls usernames from an excel sheet and creates a folder/sets permissions for each user. I'm getting the following error when running it:
Line: 26
Char: 110
Error: Cannot use parentheses when calling a Sub
Code: 800A0414
Source: Microsoft VBScript compilation error
The code is posted in its entirety below:
Code:
Dim oFSO, oExcel, oSheet, sUser, iRow
iRow = 2
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oExcel = CreateObject("Excel.Application")
Set oSheet = oExcel.Workbooks.Open("C:\Documents and Settings\Administrator\Desktop\student.xls")
Do Until oExcel.Cells(iRow,5).Value= ""
sUser=oExcel.Cells(iRow,5).Value
iRow = iRow+1
Call HomeDir()
Loop
oExcel.Quit
Wscript.Quit
Sub HomeDir()
Dim sHome, sHomeDir, oFolder
sHome = "D:\roamingprofiles2\"
sHomeDir = sHome&sUser
If oFSO.FolderExists(sHomeDir) Then
Set oFolder = oFSO.GetFolder(sUser)
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
The line the error references is the oShell.Run line. The file is saved as a .vbs file.
Any thoughts? Thanks!