2

I a batch file that fix permissions in ALL the Tree of a docomentum storage. it sits in a UNC operation directory.

goSetPriv.bat

@echo off   
set /a _cnt=0
set _docdir="UNC_DCTM_PATH_TO_SCAN\*"
if (%1) NEQ () set _docdir="%*"
set _start=%date:~4,10% %time%

pushd UNC_OF_OP_DIR
FOR /D %%I in (%_docdir%) DO (
    icacls %%I /grant:r ssis_admin:R /inheritance:e > nul
    call :counter
)
......

counter:
......

When I run goSetPriv as a scheduled task (Higest privileges , Windows 7 Server 2008R2) PROGRAM: \O:\goSetPriv.bat

It runs quickly over all the parent directories without changing their permissions of the sub-directories and files within them. When I run the batch without straight from cmd (i.e O:>goSetPriv.bat) it does the job slowly changing all the sub-folders and files within the all the parent directories.

Where is the problem ?

Thank you

1 Answers1

0

Solved

pushd UNC_OF_OP_DIR
FOR /D %%I in (%_docdir%) DO (
    icacls %%I /grant:r ssis_admin:R /inheritance:e /T
)

For some reason manually running this batch will traverse all files and subfolders (doesn't prompt files). When you run it as a scheduled task you must implicitly add the traversing switch (does prompt files)