I have a batch script that goes and deletes all files and folders within the "Temp" folder of each users profile, without deleting the main directory. The script will delete the files just fine but when it gets to the subfolders I get "The system cannot find the path specified." error.
@echo off
cd /D c:\Users
for /D %%a in (*.*) do del /f/s/q "%%a\appdata\local\Temp\"
for /D %%a in (*) do RMDIR /s/q "%%a\appdata\local\Temp\*"
I've tried as explained in this post: Batch file to perform start, run, %TEMP% and delete all, but the directory "Temp" gets deleted, just need files and subfolders within the parent Direcotry (Temp) to be removed.