scripting help

dphantom

Diamond Member
Jan 14, 2005
4,763
327
126
Here's the background.
I need to copy folders/files from Novell to Windows NTFS using Robocopy. Also need to set user permissions.

The folders are the current users home folders in Novell. So each user must be assigned permission only to their home folder identified by their username. (Some exceptions but I'll deal with them later)

I've hashed togther from various sources a couple of scripts/batch files but am stuck on how best to create a single script without calling individual vbs or batch files. The first copies the files/folders over. Then it calls a vb script to assign appropriate permissions.

@ECHO OFF
SETLOCAL

SET _source=c:\testing

SET _dest=c:\temp

SET _what=/COPYALL /MIR


SET _options=/R:0 /W:0 /LOG:UserLogfile.txt /NFL /ETA /TEE

ROBOCOPY %_source% %_dest% %_what% %_options%

setuseracl.vbs

The vbs script is listed below.

Option Explicit
Dim intRow, objExcel, objSheet, strPathExcel
Dim strHomeFolder, strHome, strUser
Dim objFSO, objShell, intRunError

' Note you will have to amend the following variables
strHome = "c:\temp\"
strPathExcel = "c:\newUsers.xls"
intRow = 2 ' Row 1 contains headings

' Open the Excel spreadsheet
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objExcel = CreateObject("Excel.Application")
Set objSheet = objExcel.Workbooks.Open(strPathExcel)

' Create a shell for cmd and CACLS
Set objShell = CreateObject("Wscript.Shell")

' Here is the loop that cycles through the cells
Do Until (objExcel.Cells(intRow,1).Value) = ""
strUser = objExcel.Cells(intRow, 1).Value
call HomeDir ' I decided to use a subroutine
intRow = intRow + 1
Loop
objExcel.Quit ' Clears up Excel


Sub HomeDir()
strHomeFolder = strHome & strUser
If strHomeFolder <> "" Then
If Not objFSO.FolderExists(strHomeFolder) Then
On Error Resume Next
objFSO.CreateFolder strHomeFolder
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Cannot create: " & strHomeFolder
End If
On Error GoTo 0
End If
If objFSO.FolderExists(strHomeFolder) Then
' Assign user permission to home folder.
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls "_
& strHomeFolder & " /c /g XXX.com\Administrator:f "_
& strUser & ":c", 2, True)
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions for user " _
& strUser & " to home folder " & strHomeFolder
End If
End If
End If
End Sub


What I would like to do is make a single script that calls Robocopy and then assigns permissions to the home folder user as well as any other domain account I may want to add to a particular folder (backup account comes to mind).

Any help is most appreciated.