Batch File Delete Temp

Dell Studio 1537
January 16, 2009 at 11:30:49
Specs: Windows Vista, T5900/3G
Hello Everyone,

Recently I've been working on a multifunctional batch file that will make deleting, reformatting, cleaning, transferring, and locating files quickly. Anyways one of my function in the file is to Delete "Temporary Internet Files" and Temp files from my computer. I have came up with the following code which is somewhat successful.

echo Deleting Files
Del /F /S /Y C:\Users\%Username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\
DEl /F /S /Y %TEMP%
echo Complete

Note this is just Part of my code not the whole thing.

So anyways when it goes to delete the "Temporary Internet Files" it says "The system could not find the file specified" Then I tested maybe I Had the %username% input variable wrong so I skipped that and just put my User name in their and it still didn't work, I think this may be due to the fact that the file in the folder "Temporary Internet Files" are hidden and so is Appdata which is like the fourth parent to that file.

So anyways my question is. Is there anyone to access those folders with another batch file command or maybe something like I did for TEMP, also is there a way to override the Hidden folder so it deletes them anyways, and finally if you could help me out on this one is their any other TEMP folders or files that could be deleted and remember I"m using vista so the directories may be different if you not using Vista.

And please don't just tell me "Oh you could easily do this with CCleaner" I'am well aware that CCleaner is a great free application that can do a lot of this but I really what to create this myself.

See More: Batch File Delete Temp

Report •

January 16, 2009 at 13:45:42
There are spaces in the path so Del is probably looking for a file named C:\Users\%Username%\AppData\Local\Microsoft\Windows\Temporary

Try enclosing the path in double quotes " {path} "

Report •

January 16, 2009 at 14:14:23
If you want to delete the folder and
everything in it, try using the deltree
command. So try:
cd C:\Users\%Username%\AppData\Local\Microsoft\Windows\
deltree Temporary

I think that should solve your problem.

If you give up, might as well give up everything in life.

Report •

Related Solutions

Ask Question