Jump to content

Automatically controlling Win Temp Folder


MiKl

Recommended Posts

Hi Guys,

sorry if this has been discusssed before or if it seems trivial.

However, on my system the temp folder increases in content and size pretty quickly because some files just stay there.

So I thought about a batch in autostart just deleting them but there is always the danger that some files that may still be needed - maybe for completing an installation, etc. - are deleted.

So the solution would be to just delete files that are of a certain age and fortunately I found a cool little proggy.

It is called DELAGE32 and can be downloaded here from the authors page.

The awesome thing about the app is that you have several parameters for fine tuning.

I created a batch with these settings.

@echo off

"... your path ... \delage32.exe" C:\WINDOWS\Temp\*.* 2 /includeH /includeRO /quiet

*.* :all files to be deleted but it could also be *.tmp, etc. !

2 :means that ONLY files older than 1 day are deleted (Not folders !!). Could be any number - even 1.

/includeH :also hidden files

/includeRO :also read-only files

/quiet :no action from user needed

After the first use the size of my temp folder decreased from around 20MB down to 4MB. Right now it is 2.5MB.

I love it and it can also be used on the recycle bin, etc.

Best wishes, MiKl

Link to comment
Share on other sites

  • 1 month later...

Such leftovers may cause huge problems. Some virii place their components in the temporary folder and they launch at startup.

There's many years since I used the set of commands below in AUTOEXEC.BAT and I don't recall ever having a problem with an installation:

@DELTREE /y C:\windows\cookies >NUL
@DELTREE /y C:\windows\history >NUL
@DELTREE /y C:\windows\locals~1\tempor~1 >NUL
@DELTREE /y C:\windows\tempor~1 >NUL
@DELTREE /y C:\windows\temp >NUL
@MD C:\windows\temp >NUL

The above will remove any traces of cookies, document history, temporary internet files (from IE only) and the Temp folder, then it recreates Temp.

In the extreme situation that an application does require files in Temp upon reboot, you may temporarily disable deletion and recreation of Temp (place REM in front of each of the last two lines).

Oh and I never use Recycle Bin, it's completely disabled - everything I delete goes directly into the void. Virii do have the nasty habit of hiding in there too.

Link to comment
Share on other sites

  • 2 weeks later...

Going all the way back to Windows 98, I've been using a batch file to do my daily housework (cleanup) on my PC.

It runs from a shortcut on my desktop and also a shortcut in my 'Startup' folder.

I started with the batch file lines in the former post, and then added a few more, specific to my own PC, to also delete the cache from Firefox, the Prefetch folder, the Recycle Bin, etc. *

* When using Deltree.exe, if you create a line that says "Deltree /y "C:\temp" it will totally remove the 'temp' folder. That's not exactly what we need to do. We only need to empty the folder, not delete it. So the line should actually read, "deltree /y "C:\temp\*.*"

That will empty the folder and leave the folder itself alone.

Do that with every folder that you desire to "Empty".

Or you can get specific.....deltree will let you just delete a certain file or group of files from a folder.

For instance I found very old temp files in my Windows folder, so the Deltree command to clean up that little mess would read:

Deltree /y "C:\Windows\*.tmp"

where only the temp (.tmp) files would be deleted and all other files would be left alone.

The Deltree.exe command is probably the most versatile and powerful command ever written into DOS by MS. I hate that they opted to abandon it in XP and won't even let it run in later OS's.

They did, however, expand the options for the Delete command that can be used instead.

Even .tmp files and Temporary Internet Files are stored in multiple locations in Windows, so those locations can be added to your XPCleanup batch file. Just do a file search for .tmp and you'll find all their hiding places. Add all those locations to your own cleanup batch file.

Your own cleanup batch file will grow exponentially as you search out locations where junk files like to hide.

My own XPCleanup batch file is now about thirty lines long. :wacko:

But it still takes only a few seconds to run.

I put a generic copy of my XPCleanup.bat program on my web site for quick and easy download.

www.drwho.in

All the way, up through Windows ME, the "Deltree.exe" file was present in Windows. But for XP the file had to be copied over from a previous OS. And, to keep things simple, I just put it in the root directory. It will not run at all in Vista, Win-7 & Win-8. You have to use the Delete command on those OS's.

That modified batch file is in my Windows 7 Stuff .rar file on my website.

Just for fun, I wrote a modified XPCleanup batch file, that first counts all the files on the C drive, and then deletes all the common junk files, then counts the files again and posts the difference.

That's the number of junk files that it deleted. I like to run that on PC's that I've never worked on before, that still run XP. On one recent house-call, I ran that on a man's PC and it took out over 100,000 junk files. We had a nice little chat for the several minutes that it took that program to run.

His complaint was, "my PC is running so slow, I can't stand it anymore!".

Oh yes, that PC also had several hundred trojans and pieces of Spyware on it.

Once de-bugged, tweaked and cleaned, that little PC ran better than new.

Keeping one's PC clean, neat, defragmented and running at top performance, isn't rocket science, , , it's just a matter of using what has already been supplied to us in Windows (and sometimes DOS).

Again, for max OS efficiency, I highly recommend that anyone wanting to run XP/SP3, do try to get up to 2 gig's of ram installed.

Yes, XP will run on 256 meg's of ram, but not efficiently. Two gig's seems to be the sweet spot.

Long Live XP!

B)

Edited by Andromeda43
Link to comment
Share on other sites

If I recall correctly, there's the RD (remove directory) command in NT-based Windows as a counterpart for 9x's DELTREE. I'm not sure, however, if ti works for non-empty directories or what are the accepted parameters, if any.

XP (and probably later versions too) can automatically run batch files at startup and upon shutdown.

Start > Run > gpedit.msc > Enter/OK will open up the Group Policy editor.

Computer configuration > Windows settings > Scripts (Startup/Shutdown)

Add the batch scripts to be run on startup and/or shutdown, respectively.

Link to comment
Share on other sites

If I recall correctly, there's the RD (remove directory) command in NT-based Windows as a counterpart for 9x's DELTREE. I'm not sure, however, if ti works for non-empty directories or what are the accepted parameters, if any.

Sure it does, with the "right" switches:

http://ss64.com/nt/rd.html

In case of need....:

BUT here we are in "Windows 9x / ME".... :ph34r:

jaclaz

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...