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.
DELcommand?C:\Users, and they're also free to modify the locations of their%TEMP%and/or%TMP%directories. I would also add, that you should not be deleting everything from the temporary directory and that Windows has a Disk Cleanup utility which would be a safer method of dealing with these things.Administrator,All Users,Default,Default UserandPublic, all of which are likely to exist as directories under yourC:\Userslocation. And please heed my advice about theDisk Cleanuputility, it is without a doubt a better way to manage unnecessary temporary files than this.