I'm not changing the rules, I'm throwing out options and ideas.
code:
BREAK ON
$DIR=F:\
SHELL "CMD.EXE /E:1024 /C DIR $DIR *. /AD /B /N > $DIR\DIRS.TXT"
Open(2,"$DIR\DIRS.TXT",4)
WRITELINE (2,"999999999")
CLOSE(2)
$INDEX2 = 0
$COUNT2 = 0
$index = 0 ; This index is used to count directories
$count = 0 ; This count is used to determine how many directories have been changed
SHELL "CMD.EXE /E:1024 /C CACLS $DIR > $DIR\CACLS.TXT"
$DIRLOC = $DIR
Open(1,"$DIR\CACLS.TXT",4)
WRITELINE (1,"THEEND")
CLOSE(1)
Open(1,"$DIR\CACLS.TXT",2)
Open(2,"$DIR\DIRS.TXT",2)
GOTO READACL
:SUBS
; This section reads each line of DIRS.TXT file with the directory information in it.
$D = ReadLine(2)
; "$D"
; This secition will take the output file with the ACL information
; and wrote THEEND at the end of it to mark the end of the file
$DIRLOC='$DIR'+'$D'
? "$DIRLOC"
$shellstring2='cacls ' + '"$DIRLOC"'+ ' >' + ' "$DIRLOC' + '\CACLS.TXT"'
? "$SHELLSTRING2"
; SHELL "CMD.EXE /E:1024 /C CACLS $DIRLOC > $DIRLOC\CACLS.TXT"
shell '%COMSPEC% /e:1024 /c '+$shellstring2
Open(1,'$DIRLOC' + \CACLS.TXT,4)
WRITELINE (1,"THEEND")
CLOSE(1)
Open(1,$DIRLOC + \CACLS.TXT,2)
; This section reads each line of the CACLS.TXT file with the ACL information in it.
; If the line has D01\ in it, the program will extract the user name or group name
; associated with D01\ and make it the $NAMEGRP variable
:READACL
$X = ReadLine(1)
; ? "$X"
IF $X = "THEEND"
CLOSE(1)
$COUNT2 = $COUNT2 + 1
$INDEX2 = $INDEX2 + 1
Goto SUBS
Endif
IF $X = "999999999"
Goto Done
ENDIF
IF INSTR ("$X", "EVERYONE")
$Account = split(split($X,":")[0],"\")
$NAMEGRP = LTRIM($Account[0])
; ? "$NAMEGRP"
GOTO PERMISSION
ENDIF
IF INSTR ("$X", "D01\") <> 0
$Account = split(split($X,":")[0],"\")
$NAMEGRP = $Account[1]
; ? "$NAMEGRP"
GOTO PERMISSION
ELSE
GOTO COUNT
ENDIF
:PERMISSION
$P = SUBSTR($X, LEN(RTRIM($X)), 1)
; ? "$P"
IF $P='N' OR $P='R' OR $P='W' OR $P='C' OR $P='F'
; This section will take the $NAMEGRP variable and add an ACL for the same user or group
; in the BIO domain. Giving that user or group None, Read, Write, Change or Full Control.
; $shellstring='cacls ' + '$DIRLOC'+ ' /E /t /g' + ' BIO\' + '$NAMEGRP' + ':' + '$P'
$shellstring='cacls ' + '$DIRLOC'+ ' /E /g' + ' BIO\' + '$NAMEGRP' + ':' + '$P'
; shell '%COMSPEC% /e:1024 /c '+$shellstring
? "$shellstring"
ENDIF
:COUNT
$count = $count + 1 ;increase the count of directories
$index = $index + 1 ;increment index for next pass
goto READACL ;loop and read next ACL
CLOSE (1)
CLOSE (2)
:Done
? "Done!"
? ""