Temp dir - deleting contents on shutting down

D

Dave Horne

Is there a way to automatically delete the contents of the Windows\Temp dir
when shutting down the computer?
 
M

Mike Brannigan

Dave Horne said:
Is there a way to automatically delete the contents of the Windows\Temp
dir when shutting down the computer?

Yes using a local group policy assign a machine shutdown script to remove
the contents of the drive or do anything else you want as the machine shuts
down.
Open the Help and Support and search for local group policy
 
D

Dave Horne

Mike, what I was looking for was an automatic deleting of files in the Temp
dir upon shutting down. I looked under Help and Support and was given
instructions on how to manually delete files using Disk Cleanup or IE \
General \ Browsing history. I was wondering if there is a way for me to
have the contents of that Temp dir emptied on shutdown. Under older
versions of Windows we could add a line to the autoexec.bat to perform tasks
like this.

Thanks, DH
 
M

Mike Brannigan

Dave Horne said:
Mike, what I was looking for was an automatic deleting of files in the
Temp
dir upon shutting down. I looked under Help and Support and was given
instructions on how to manually delete files using Disk Cleanup or IE \
General \ Browsing history. I was wondering if there is a way for me to
have the contents of that Temp dir emptied on shutdown. Under older
versions of Windows we could add a line to the autoexec.bat to perform
tasks
like this.

Thanks, DH

Yes and under modern Windows operating system you use a local group policy
and a shutdown script to do anything you want when you shutdown the PC
including cleaning up folders etc.
Just write a simple script (a bat or cmd file) to delete the contents of the
folders you want and then set it as the shutdown script for the PC using the
local group policy tool.
Simple.


--

Mike Brannigan
Dave Horne said:
Mike, what I was looking for was an automatic deleting of files in the
Temp
dir upon shutting down. I looked under Help and Support and was given
instructions on how to manually delete files using Disk Cleanup or IE \
General \ Browsing history. I was wondering if there is a way for me to
have the contents of that Temp dir emptied on shutdown. Under older
versions of Windows we could add a line to the autoexec.bat to perform
tasks
like this.

Thanks, DH
 
T

Terry

On 5/1/2007 5:11 AM On a whim, Dave Horne pounded out on the keyboard
Mike, what I was looking for was an automatic deleting of files in the Temp
dir upon shutting down. I looked under Help and Support and was given
instructions on how to manually delete files using Disk Cleanup or IE \
General \ Browsing history. I was wondering if there is a way for me to
have the contents of that Temp dir emptied on shutdown. Under older
versions of Windows we could add a line to the autoexec.bat to perform tasks
like this.

Thanks, DH


Mike Brannigan said:
Yes using a local group policy assign a machine shutdown script to remove
the contents of the drive or do anything else you want as the machine
shuts down.
Open the Help and Support and search for local group policy

Hi Dave,

I still use a batch file, but put it into the startup folder. It's not
a good idea (IMO) to clear the folder on shutdown, as files may be
placed there during an install that are needed on restart. It's safer
to clear it on startup as the Startup folder is the last thing to get
processed on boot.


--
Terry

***Reply Note***
Anti-spam measures are included in my email address.
Delete NOSPAM from the email address after clicking Reply.
 
R

Richard Urban

You never, ever, want to do that. You will break many application installs
by doing so.

Many applications finish their install upon a reboot, whether they tell you
to reboot - or not. Guess where the files needed to complete the
installation are placed?

--


Regards,

Richard Urban
Microsoft MVP Windows Shell/User
(For email, remove the obvious from my address)

Quote from George Ankner:
If you knew as much as you think you know,
You would realize that you don't know what you thought you knew!
 
C

Chris Barnes

Richard said:
You never, ever, want to do that. You will break many application installs
by doing so.

Many applications finish their install upon a reboot, whether they tell you
to reboot - or not. Guess where the files needed to complete the
installation are placed?


Fair enough.

But continuing the original thread - is there then a way to "remove all
files in the ~temp directory that are older than "x days"?
 
J

John Barnes

Selective use of CCleaner.

Chris Barnes said:
Fair enough.

But continuing the original thread - is there then a way to "remove all
files in the ~temp directory that are older than "x days"?
 
M

MICHAEL

* Chris Barnes:
Fair enough.

But continuing the original thread - is there then a way to "remove all
files in the ~temp directory that are older than "x days"?

CrapCleaner has a "only delete files older than 48 hours" option.

Options>Advanced


-Michael
 
A

Adam Albright

Fair enough.

But continuing the original thread - is there then a way to "remove all
files in the ~temp directory that are older than "x days"?

Richie doesn't have a clue. He's proved that over and over. A
temporary file is just that... temporary and can be safely delted ONCE
there is no longer any use for it. In fact if any temp file is in use,
you can't delete it, Windows won't let you, saying the file is in use.

Temporary files can accumulate for several reasons. Either some dumb
application doesn't clean up after itself, or if you suffer a crash
some files may be left in limbo. Generally I would wait a day or two
before deleting any .tmp file. After that, no harm in cleaning up.

Try this...

Do an ANVANCED search that includes all your hard drives and sets the
parameters to 'everywhere' and also includes hidden system files using
the search string: .tmp then just sit back and wait a few minutes.

CAUTION, be careful, Windows is DUMB enough such a search may return
anything with the string 'tmp' anywhere in the file's name or path
meaning if you're not careful you could delte files you had no
intention of deleting. So as a first step once the results of the
search are returned click on the column titled type and be sure you
only remove. .tmp files!

You may be shocked at the amount of garbage on your system.

I haven't checked mind in awhile to see what Windows left behind till
now. Well my goodness, lets see how DUMB Vista really is.

The first thing that jumps out at me is there are 204 files all
starting with lpksetup. What the heck is this? Oh, just some goofy
language pack some web site wanted to install to properly view their
web site and it failed. Now opening one of these files in Notepad just
to see what's inside. Basically a useless error report that in part
said:

failed to remove directory blah, blah, with error 3.

08:29:29:276 : PERF: Enumerating installed languages - LEAVE
08:29:29:432 : INFO: There are no languages to cleanup
08:29:29:542 : PERF: RestorePointEnd - ENTER
08:29:29:667 : PERF: RestorePointEnd - LEAVE
08:29:29:792 : DEBUG: Cleaning working path in a new process

plus more blah, blah, blah.

Now I can leave this file, it does no harm, but consider what happens
if you leave it. This particular file is just 4Kb, others in the 204
total are a little smaller or bigger, some are even 0 length. But
wait... they all take up 4,096 bytes since that's the sector size of
the hard drive they're on. So in effect that's 204 x 4,096 = 835,584
bytes or getting close to a whole GB just wasted with garbage. Kind of
dumb if you have a disk that's running out of room, you may want to
recapture such wasted space.

Don't be fooled into thinking that .tmp files only show up in some tmp
folder. That's not true. They often get written to a application's
primary folder which is likely on your root drive under program files.

So yes, you can sort to see what's there and yes you can delete
selected files right from the search results. Just proceed with
caution. Better to leave some garbage if you're not sure, then to
delete it thinking it won't harm anything, then later find out it did.
A good way to test that is first clean out your Recycle Bin getting
rid of stuff you know you'll never need. Next look at your .tmp files,
delete those you think you won't need. Now confirm they are in the
Recycle Bin. Reboot. If your system runs ok, especially the
application that created the tmp file, wait a day or two then
generally you can empty the recyle bin and reclaim the wasted file
space. If something doesn't seem to work right just restore the files
you were going to delete from the Recycle Bin.
 
T

Terry

On 5/1/2007 9:47 AM On a whim, Adam Albright pounded out on the keyboard
Richie doesn't have a clue. He's proved that over and over. A
temporary file is just that... temporary and can be safely delted ONCE
there is no longer any use for it. In fact if any temp file is in use,
you can't delete it, Windows won't let you, saying the file is in use.
<snip>

There isn't anything RU stated that wasn't true. He said that if a
program install places files in the temp folder and requires a reboot,
that removing the files on shutdown would remove the required files.
That is a fact (although not ALL programs do this, many do).

Placing the batch file into the Startup folder on the other hand gets
processed after any install procedures, thereby eliminated the problem.

--
Terry

***Reply Note***
Anti-spam measures are included in my email address.
Delete NOSPAM from the email address after clicking Reply.
 
R

Richard Urban

Use CCleaner and configure the advanced options. By default, temp files are
kept for 48 hours. You can also set CCleaner to empty the temp folders on
startup, leaving any files that may be necessary for that 48 hour period.

I can not begin to tell you how many programs and small applications I have
installed that do not require a reboot. Yet if you do reboot you may see a
message to wait while the system is being configured. It is the temp files
that are being accessed to use during the configuration.

Hence, do not empty the temp folders on reboot/shutdown.

--


Regards,

Richard Urban
Microsoft MVP Windows Shell/User
(For email, remove the obvious from my address)

Quote from George Ankner:
If you knew as much as you think you know,
You would realize that you don't know what you thought you knew!
 
T

Terry

On 5/1/2007 10:19 AM On a whim, Richard Urban pounded out on the keyboard
Use CCleaner and configure the advanced options. By default, temp files are
kept for 48 hours. You can also set CCleaner to empty the temp folders on
startup, leaving any files that may be necessary for that 48 hour period.

I can not begin to tell you how many programs and small applications I have
installed that do not require a reboot. Yet if you do reboot you may see a
message to wait while the system is being configured. It is the temp files
that are being accessed to use during the configuration.

Hence, do not empty the temp folders on reboot/shutdown.

I agree on shutdown. But I have placed batch file clear temp files into
Startup folders on every system I have ever configured. There has never
been one instance of an install failing when cleaning the temp folders
by using the Startup folder. The Startup folder is the last one processed.

I do not recommend any other startup location as others have mentioned,
since they may get processed prior to a program installs final
configuration.

--
Terry

***Reply Note***
Anti-spam measures are included in my email address.
Delete NOSPAM from the email address after clicking Reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top