This is actually working but not in the format I prefer. The code below will achieve what I want. Makes a folder in any writable standard User Profile (I am aware it wont work in some system profiles like Default etc.) that some software needs and also gives it relevant permission.
for /d %%A in ("C:\Users\*") do mkdir "%%~fA\AppData\Local\Folder1"
for /d %%A in ("C:\Users\*") do mkdir "%%~fA\AppData\Local\Folder1_Ltd"
for /d %%A in ("C:\Users\*") do icacls "%%~fA\AppData\Local\Folder1" /T /C /grant(:r) "Everyone":(OI)(CI)(F) /inheritance:e
for /d %%A in ("C:\Users\*") do icacls "%%~fA\AppData\Local\Folder1_Ltd" /T /C /grant(:r) "Everyone":(OI)(CI)(F) /inheritance:e
This seems a bit over the top though. I am wanting to just have the one loop through the user folders and then use brackets to list the commands, saving a user loop for every function. However when I try the below, it doesn't even make the folders. If I debug using command line it stops at "everyone" was unexpected at this time. I'm not sure why? Any advice be welcome, thanks.
for /d %%A in ("C:\Users\*") do (
mkdir "%%~fA\AppData\Local\Folder1"
mkdir "%%~fA\AppData\Local\Folder1_Ltd"
icacls "%%~fA\AppData\Local\Folder1" /T /C /grant(:r) "Everyone":(OI)(CI)(F) /inheritance:e
icacls "%%~fA\AppData\Local\Folder1_Ltd" /T /C /grant(:r) "Everyone":(OI)(CI)(F) /inheritance:e
)
pause
You could use WMI to access only normal users profiles too:
@Echo Off
For /F "Skip=1 Delims=" %%A In (
'"WMIc Path Win32_UserProfile Where (Special!='True') Get LocalPath"'
) Do For /F "Delims=" %%B In ("%%A") Do Call :Sub %%B
Pause>Nul
GoTo :EOF
:Sub
For %%A In (Folder1 Folder1_Ltd) Do (If Not Exist "%*\AppData\Local\%%A\" (
MD "%*\AppData\Local\%%A")
ICACLS "%*\AppData\Local\%%A" /T /C /Q /grant:r Everyone:(OI^)(CI^)F /inheritance:e)