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

  • Roey - I wanted to give you some tips and a resource that should help you fully resolve this issue. You don't need to put the cmd.exe in the program and should rather just put the full path of the script, and use the argument field for those and use the start in path too even tho it is optional. See here: i.imgur.com/EU2nHe1.png for an example of what I'm talking about. You also want to be sure to run with highest privileges from the general tab. – Pimp Juice IT Jul 8 '17 at 14:59
  • Furthermore, see my answer here: superuser.com/questions/1214736/… and just disregard the bottom section where the section name is WinSCP Batch Script Examples but everything above that should help go over everything that can cause problem with running batch script from Task Scheduler. Let me know if you find any of this helpful in getting a solution, etc. Be sure to tag me back by using the @ symbol and then followed by my name and I'll get a notice you comment back. – Pimp Juice IT Jul 8 '17 at 15:02
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)

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.