Edit: I had to change the takeown command because it wasn't right. I added /s thinking that was 'silent mode' but it's actually 'system'. And fixed a typo "missing a space".
This may help someone who wants to be able to delete a bunch of files with a click of a button or on schedule.
I was wanting to delete temp files like cookies and others that weren't getting deleted. I started off going into the directories and making favorites of the folders and then manually going into them and deleting the files. After a while I kept adding new folders to this and it got to be a pain having to go into so many folders. So I made this batch file to do it.
This works on win7 I don't know if it works on others. It will delete the files and folders in the directories. You can add other directories to it to suit your needs.
Step 1: Make a new text file and change the name to DeleteTemp.bat (call it whever you want but make sure it has .bat)
Step 2: Add the following lines to it.
rmdir /s /q %temp%
del /s /q /f %LocalAppData%\Temp*.*
del /f /s /q %userprofile%\AppData\Local\Temp*
forfiles /P %userprofile%\AppData\Local\Temp\ /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"
takeown /f "%AppData%\Microsoft\Windows\Cookies\Low" /r
del /s /q /f %AppData%\Microsoft\Windows\Cookies\Low*.*
takeown /F "%userprofile%\AppData\Local\Temporary Internet Files" /r
del /s /q /f "%userprofile%\AppData\Local\Temporary Internet Files*"
forfiles /P "%userprofile%\AppData\Local\Temporary Internet Files*" /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"
Step 3: Save the file.
Step 4: Run it.
forfiles: line will delete folders in that directory. I only needed this on certain directories.
takeown: line will give you ownership of a directory to give access to delete the files in it.
cmd /k: will just keep the prompt open after clicking on it. You can remove this line if you don't want to see the output.
Note: This doesn't delete the main directory. It leaves the directory in place. Just the files in it.