for /D /r "C:\Users" %%A in (*Folder*) do icacls "%%~fA" /T /C /grant(:r) "Everyone":(OI)(CI)(F) /inheritance:e >> %log% 2>&1
Running this code physically on a machine with a batch works perfectly. The right folders are found and permissions applied and log file displays everything. It does it for the specific folder in each users appdata folder:-
processed file: C:\Users\Administrator\AppData\Local\Folder
However if I use PSEXEC to apply the permissions remotely then it goes mental and tries to loop through a application data folder for each user millions of times which no body has access to. Where as stated before it doesn't even try and eventually fails.
processed file: C:\Users\Administrator\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\
Whats going wrong, thanks.
psexec code:-
@echo off
for /f "usebackq tokens=*" %%i in ("%~dp0pxhosts.txt") do (
xcopy /y %~dp0permsnet.bat "\\%%i\C$\Temp"
"%~dp0psexec.exe" \\%%i -accepteula -d "\\%%i\C$\Temp\permsnet.bat"
)
pause
edit answer found by applying the -s switch the process behaves as normal. @Noodles answering with correct info for anyone else with this issue