Home / Microsoft / Microsoft DOS / Remove the content of Temp Directory!???
0 Members and 3 Guests are viewing this topic. « previous next »
Pages: 1 [2]  All - (Bottom) Print
Author Topic: Remove the content of Temp Directory!???  (Read 619 times)
TheShadow
Intermediate



Thanked: 9
Posts: 220

Certifications: List
Computer: Specs
Experience: Guru
OS: Windows XP


Retiree in Florida

The Doctor 1
« Reply #15 on: November 28, 2011, 04:03:32 PM »

I saw it mentioned something to the effect that "Deltree.exe" is no more. 
Well, at least within the Windows XP community, that is far from correct.
Deltree.exe can be copied to XP from any earlier OS, like '98 or ME.
I even have it on my own web site, for an easy download.

But with the new functions built into the RD command, that's no longer necessary.
However, I too like Deltree and continue to use it in my own Cleanup batch files.

As for US old timers who just don't like JUNK forever building up on our hard drives, and sucking the life out of our PC's,
a cleanup batch file in the Startup folder is like FREE Maid Service for our PC's.

I've been using that means for keeping my PC nice and clean, Daily, for many years now.  I share that technique with my customers.  It really helps those who will never do their own maintenance.
The actual syntax has changed somewhat, since the windows 98 days, but the idea is the same.
Then with Vista, Win-7 and Win-8, where the Deltree command no longer works, I've modified my cleanup batch files to start with the DEL command.....like this:

del /F /S /Q "C:\temp\*.*"
del /F /S /Q "%systemroot%\temp\*.*"

That does essentially the same thing as using Deltree.

It's pointless to delete the actual 'temp' folder.  Windows just has to remake it on the next boot.  So don't just make extra work for windows when it's trying to boot up..... leave the 'temp' folder alone.  (Take out the junk, but leave the folder)

If you go through your own hard drive and find every folder where windows or some other program stores junk files, and then add a line containing that folder to a batch file, your cleanup batch file will probably be as long or longer than mine.
Mine is currently about forty lines long.
Oh, I'm also deleting the contents of my AVG virus vault and my Recycle Bin.

I hate junk and I try to get rid of as much of it as is humanly possible.   With the HD clean, lean and mean, scans and backups go just so much faster.

A batch file that you write yourself, can get the job done and be much safer than those 'do everything' cleanup programs like CCleaner.   

Cheers Mates!
 8)
IP logged

Experience is truly the best teacher.
Backup! Backup! Backup!  Ghost Rocks!
BC_Programmer
Mastermind


Thanked: 697
Posts: 15,876

Computer: Specs
Experience: Beginner
OS: Windows 7


Pinkie Pie is best pony

BC-Programming.com 1 1
« Reply #16 on: November 28, 2011, 04:44:47 PM »

Quote
Windows just has to remake it on the next boot.
Windows Does not create the directory if it doesn't exist at any point. If the path pointed to by %temp% (or %tmp%) doesn't exist Windows itself will store temporary files in the root of the system drive. How an application reacts depends on the application. Usually the application will encounter errors when it tries to create a file, unless it is written to handle the case where the path returned by GetTempPath() doesn't exist. Basically, deleting the temp folder itself isn't merely pointless but more apt to cause problems.



A batch file that you write yourself, can get the job done and be much safer than those 'do everything' cleanup programs like CCleaner.   

Even if the batch file is only a subset of the functionality.

Files stored on a hard drive do not slow it down. I suppose it would slow down backups, but if your backup process involves backing up temporary files... well I don't know what to say to that.

Quote
As for US old timers who just don't like JUNK forever building up on our hard drives, and sucking the life out of our PC's,
a cleanup batch file in the Startup folder is like FREE Maid Service for our PC's.
It's not so much being an old timer (from the past) as it is being 'stuck' in said past, or rather, stuck in the way of doing things. I used DOS 3.11, DOS 6, PC-DOS, and so forth myself, and wrote similar batch files to clear out the temporary files from Windows 3.1 (.WOA files being left all over the place from standard mode windows crashed, for example). But I stopped after Windows 9x, because there were far too many locations that temporary files were stored, the files stored within could often be in-use at the time the deletion was attempted, and unless I was running low on disk space it didn't really matter, and if I was running low I would run disk cleanup which would clear out those folders anyway. Not to mention, that temporary files generally only remain when the application that created them crashed or didn't delete them for some reason. Of course the occasional cleanup doesn't hurt, but to do so meticulously on a daily basis probably wastes more time than it saves in the long run. One would be better to address why their applications are crashing often enough that their temporary files are in a quantity worth deleting.

The main reason I don't like the idea of Batch files deleting temporary files is because people are often under the mistaken impression of two things:

1. that applications that use a temporary file will keep that temporary file open during the time that it is "used"
and
2. that applications that keep those files open open it with the specific share flags that will prevent a batch script from deleting it.

I don't know about anybody else, but I'd rather not trust the safety and stability of my system to such assumptions. The first is outright wrong; Many applications don't keep the file open; Photoshop, for example, has it's own swapping mechanism whereby it stores open documents that haven't been accessed and undo stacks as temporary files. However, it doesn't keep them open; instead it keeps track of the files  themselves and opens them and makes modifications as needed. If one was to delete the temporary folder contents while Photoshop was running, there is a likelihood that you could lose a lot of data. The second is an assumption. Many applications will create temporary files with FILE_FLAG_DELETE_ON_CLOSE so they will be deleted when they are closed, and they often open it with the FILE_SHARE_DELETE deletion flag, depending on the purpose of the temporary file. This means that other applications- or batch files- can delete the file while it is open by the application, which would also result in data loss.

of course, if the batch file runs at boot time, this won't be an issue, as long as one doesn't run any applications while the batch file is running. But, if it's run on a schedule, than there is no telling what can be lost. Personally, I'd rather use Disk Cleanup since it is a pre-emptive, multi-tasking Application that is designed to work co-operatively and is far less likely to delete files that it is able to detect are in use, rather than relying on specific circumstances of both the application opening the temporary file as well as the method by which it accesses said file.
IP logged

My Blog

BASeBlock 2.3.0 (NOW WITH MACGUFFINS!)
Raven19528
Hopeful



Thanked: 29
Posts: 284

Computer: Specs
Experience: Experienced
OS: Windows 7



« Reply #17 on: November 29, 2011, 11:17:51 AM »

Hello hello newsflash
Code: [Select]
rd /s /q "%userprofile%\Local Settings\Temp" this code of Raven has stopped working , last time i had to perform a System Recovery and what do you know the bat file doesn't work to well.
 It removes the TEMP folder entirely, has  anyone even been trying this out. Its really important for me.

This is the reason the original post also mentioned putting the md "%userprofile%\Local Settings\Temp" right after the rd command. Try this:

Code: [Select]
rd /s /q "%userprofile%\Local Settings\Temp"
md "%userprofile%\Local Settings\Temp"

Any suggestion i have to be better aware next time when i thank someone.
Little help here.

Not necessary or welcome. To borrow a line from a fellow board member, "Your membership fees determine the level of service you are guaranteed."
IP logged

"All things that are
Are with more spirit chased than enjoy'd" -Shakespeare
Pages: 1 [2]  All - (Top) Print 
Home / Microsoft / Microsoft DOS / Remove the content of Temp Directory!??? « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.194 seconds with 19 queries.