# deleting temp files



## riceburneR1 (Mar 10, 2004)

i was wondering if it is ok to delete temp files in .../local setting/temp in windows


----------



## DaveBurnett (Nov 11, 2002)

Yup. I do it in a batch file that is run at startup. Just make sure that you don't install software from it as some need to reaccess the files after a restart.


----------



## aarhus2004 (Jan 10, 2004)

Hi DaveBurnett,

Wanna share your batch file?


----------



## DaveBurnett (Nov 11, 2002)

Change all the temp and tmp enviroment variables to point to C:\TEMP then use:

@echo off
c:
cd \
rd /s /q C:\temp
md temp
echo done

save it as a bat file and put it in the startup folder.


----------



## aarhus2004 (Jan 10, 2004)

Hello Dave,

You have a real live newbie on your hands. However thanks for responding.

I do not understand how to change the temp and tmp variables to point to C:\TEMP. Can you help with that?

Please correct me if I am mistaken but I think your code is solely designed to clear files which can be cleared manually. Is this so?

Thanks.

PS. What name for the batch file?

And is there another name for the startup folder?


----------



## Bold_Fortune (Jan 3, 2003)

> _Originally posted by riceburneR1:_
> *i was wondering if it is ok to delete temp files in .../local setting/temp in windows *


Is this the location you are looking at, aarhus2004:

C:\Documents and Settings\YOUR USERNAME\Local Settings

If so, that particular location is the location most programs place their temp files for installation.

Yes, they are safe to delete...however, it's a good idea to restart your computer first, after installing a program. Sometimes programs finish their installation upon a restart.


----------



## aarhus2004 (Jan 10, 2004)

Hello Bold_Fortune,

"C:\Documents and Settings\YOUR USERNAME\Local Settings"

Whilst that seems meaningful to yourself, DaveBurnett and riceburneR1 I cannot relate to it!

Is it because your operating system is other than Me?

That is a path isn't it? I have a Documents folder. Its all personal stuff. As for YOUR USERNAME and Local Settings. I cannot remember having come across those two.

Strange. can you help point me somewhere?

Thanks.


----------



## Bold_Fortune (Jan 3, 2003)

Sorry for the confusion. I assumed you were discussing XP.


----------



## DaveBurnett (Nov 11, 2002)

> Sorry for the confusion. I assumed you were discussing XP.


So did I.

I haven't got an ME system to try this on, so I'm not sure if it will work. This Is what I do on 98se.

Add these lines to your autoexec.bat.

deltree /y c:\tmp
c:
cd \
md tmp
set temp=c:\tmp
set tmp=c:\tmp

If it complains about not being able to find deltree when it runs , replace that line with:
rd /s /q C:\tmp

You should then go into C:\Windows\temp and delete the contents.


----------



## aarhus2004 (Jan 10, 2004)

Hello Dave,

Thanks for that. Will try it. And post.


----------



## aarhus2004 (Jan 10, 2004)

Hello Dave,

See below the last lines of my C:\WINDOWS\autoexec.bat

I am unsure as to where to place, in that sequence, your sequence.

What is this meant to achieve, since your last comment was *" You should then go into C:\Windows\temp and delete the contents."*

I thought that deletion was the object of the exercise?

:QUIT
call fixit.bat
rem clean up environment variables
set CDPROB=
set CDROM=
set LglDrv=
GOTO QUICK

:QUICK


----------



## DaveBurnett (Nov 11, 2002)

They should go in the C:\autoexec.bat

Post the contents of that - if any, it may be empty - and I'll shoew where.



> You should then go into C:\Windows\temp and delete the contents


Just the once - thereafter the code will take care of it.


----------



## aarhus2004 (Jan 10, 2004)

Hello Dave,

Here they are. They look liked the environmental variables to me, so I thought "Why there?"




SET COMSPEC=C:\WINDOWS\COMMAND.COM
SET windir=C:\WINDOWS
SET winbootdir=C:\WINDOWS
SET BLASTER=A220 I7 D1 H5 P330 T6
SET CTSYN=C:\WINDOWS
SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND
SET PROMPT=$p$g
SET TMP=C:\WINDOWS\TEMP
SET TEMP=C:\WINDOWS\TEMP


----------



## DaveBurnett (Nov 11, 2002)

> Here they are. They look liked the environmental variables to me, so I thought "Why there?"


Correct - in fact I see half the job has been done already. Why here? At this point windows has not yet started, so none of the files will be 'in use' and can therefore be deleted. As has already been said, there will be the occasion when installing new softwhere that you will have to temporarily comment out the deltree/rd command.

These should be put after the existing lines.

deltree /y c:\temp
c:
cd \
md temp

or
rd /s /q C:\temp instead of the deltree


----------



## aarhus2004 (Jan 10, 2004)

Hello Dave,

I made the suggested change to the C:\AUTOEXEC.BAT using the deltree.

On reboot Windows made no complaint and I found no entries in either C:\TEMP or in C:\WINDOWS\TEMP.

On searching for TMP I found only Windows application folders which were empty.

I guess that's that?

And thanks for the responses, Dave.


----------



## coderitr (Oct 12, 2003)

You can use DaveBurnett's suggestion without changing the temp directory location. Replace this



> rd /s /q C:\temp
> md temp


with

rd /s /q %temp%
md %temp%

Thanks Dave. I didn't know about the /q switch. Learn something new every day.


----------



## aarhus2004 (Jan 10, 2004)

Hello coderitr,

OK but why? I used the deltree (see post above). What do those % achieve? Are you using WindowsME? Or XP? Or doen't it matter?


----------



## DaveBurnett (Nov 11, 2002)

> OK but why? I used the deltree (see post above). What do those % achieve? Are you using WindowsME? Or XP? Or doen't it matter?


In your case it makes no difference. Using the %temp% is just the general form and works whatever the SET TEMP= line says.
Mine assumes it says SET TEMP=C:|temp

Deltree is not available in 2k/XP. It was replaced with the extra RD /q switch
Yes it does work under 2k and XP except that you need to put it in the startup folder as a stand-alone bat file.


----------



## aarhus2004 (Jan 10, 2004)

Hello Dave,

Appreciate your response. Feel a little frustrated that responses in a given thread have to take into account all MS Op.Sys. Guess I can no longer absorb info as perhaps once I could.

Cheers, Dave.


----------



## GoJoAGoGo (Dec 26, 2002)

Ben:

Here's my attrib /s index.dat results:


----------



## aarhus2004 (Jan 10, 2004)

Hello Joe,

Have you any thoughts as to why we differ?

I have used the capital S in one and the alternative s in the other.
I read somewhere, that this was an "inexplicable necessity" i.e. to use the S. Curious.

Perhaps someone else will satisfy my curiosity on both points.


----------



## GoJoAGoGo (Dec 26, 2002)

I post your in the thread so we can look at them both at the same time.


----------



## GoJoAGoGo (Dec 26, 2002)

It's a hard one to figure why I had 3 more entries than you do? I get the same results whether I use a capital S or a small s.


----------



## aarhus2004 (Jan 10, 2004)

Joe,

I can't add a thing. Save to pose the question of how does one put a picture up as you did?


----------



## GoJoAGoGo (Dec 26, 2002)

To post an image inside a thread you click on the attachment and copy the URL of the attachment image and paste inside your post, then you apply the image tags. In front of the URL you add [im g] and at the end of the URL you add [/im g] (Note don't add the space after the m have img with no space, I had to put the space there or it wouldn't appear for you to see.)


----------



## aarhus2004 (Jan 10, 2004)

Remarkable stuff, Thanks, Joe.


----------



## GoJoAGoGo (Dec 26, 2002)

You're welcome Ben :up:


----------

