Trovato! Resta da procurarsi il file forfiles.exe
When I've dealt with this problem in the past (for example, auto-cleaning web log directories of anything older than 30 days) I've most commonly used forfiles.exe, which comes standard on some of the MS OSes although I don't think it's there on XP. However, it can be found in the (free) reskits, or easier if you just want the one file instead of a big install package you can search around for a copy on the net and dump it in your c:\windows\system32\ directory. If you know anyone with a copy of Windows 2003 you can get it from them, too.
Forfiles.exe command/batch file
Once you have a copy of forfiles.exe you write a simple batch file- pretty much one line:
forfiles /P PATHTOFOLDER /S /D -30 /M *.* /C "cmd /C del @path /Q"
Where PATHTOFOLDER is the full path to the directory in question (c:\windows\temp in your case?), the /S means "... and all subdirectories" if desirable, and the -30 after /D is "older than 30 days"; you can change to -10 if you want 10 days, etc. /M is file mask (*.* for all files) and /C is the command you'd run on any file matching these parameters, in this case "delete" with the /Q switch to avoid prompting.
Also, in some cases you may want it to get rid of folders as well, in which case you can add a second command to use /C "cmd /C rd @path /Q" at the end instead of the del @path /Q, which should quietly error out on non-folders but otherwise remove old folders after the files have been cleaned up. That might make your batch file look like this:
forfiles /P PATHTOFOLDER /D -30 /M *.* /C "cmd /C del @path /Q"
forfiles /P PATHTOFOLDER /S /D -30 /M *.* /C "cmd /C rd @path /Q"
Try this on a copy of a folder first to test it out... I can't stress this enough, copy some folder to c:\TEST or something, and try all your batch jobs out there as the PATHTOFOLDER, so you're sure you've done the syntax as I have above and it works... before you point it at any actual directory for the love of god and all that is holy.
Schedule in AT or task manager
Save this command line in a simple text CleanTemp.bat file using notepad- you can repeat the line multiple times in the CleanTemp.bat file if you want to do this with more than one folder as a target, or using the "remove directory" example I mentioned above. Every time you run it, it'll execute those commands in the background. Then have that scheduled to run via task scheduler and it's GUI, or the AT command at a command propmt, whichever is simpler for you. Ex:
at 9:00a /every:Su,M,T,W,Th,F,S c:\scripts\CleanTemp.bat
where c:\scripts\cleantemp.bat is the full path to the batch file. This will run it automatically at 9am every single day. You can type AT at the command line with no arguments to see any existing schedule jobs. Adjust to taste, add seasoning.