Is it safe to delete AppData\Local\Temp?

134

29

  • I seem to have a lot of junk files in %appdata%\Local\Temp (also accessible via environment variables %TEMP% and %TMP%).
    Is it safe to delete these?

  • Also, is it safe to delete the Temp folder in the Windows directory, C:\Windows\Temp?

agz

Posted 2013-03-26T20:34:37.627

Reputation: 6 820

7Without being pedantic three years later, %APPDATA%\Local\Temp doesn't exist, you mean %LOCALAPPDATA%\Temp – adampski – 2016-03-16T10:26:47.783

1Or %APPDATA%\Temp – DavidPostill – 2016-05-12T22:08:23.693

3@DavidPostill %LOCALAPPDATA%\Temp and %APPDATA%\Temp are not the same (Windows 10). %LOCALAPPDATA%\Temp goes to C:\Users\<username>\AppData\Local\Temp (similar to %TEMP% and %TMP%) while %APPDATA%\Temp attempts to reach out to C:\Users\<username>\AppData\Roaming\Temp – thilina R – 2016-09-28T13:13:12.097

@thilinaR I'm well aware of that. It has been that way since Windows 7. I'm not sure what your point is. I was pointing out that the question is badly written. – DavidPostill – 2016-09-28T13:18:06.013

4Since you mentioned %LOCALAPPDATA%\Temp or %APPDATA%\Temp, I just wanted to point out that they were different. That's all – thilina R – 2016-09-28T13:21:20.650

Answers

61

Some programs keep important files in there, surprisingly. If you are interested in freeing some space I'd advise to only delete the files excluding those that were created in the last 24h or so, or the ones you know for sure aren't used by other programs, such as old installers from software you downloaded, etc. You can use software such as CCleaner to do that.

The answers to this question provide ways to do this clean-up safely and automatically.

Alex

Posted 2013-03-26T20:34:37.627

Reputation: 1 619

25"Some programs keep important files in there" - a couple of people have mentioned this, but can anyone give an example? Also, wouldn't this be broken behaviour on the part of that program? Do we need to cater to this broken behaviour? – thomasrutter – 2015-04-08T06:37:52.330

5@thomasrutter I made that remark because I remembered having issues with some software a few years ago. That was two years ago, so the issues I encountered are at least three years old. I have no idea if current software still has the practice of keeping files there, since I haven't used Windows since. It's easy to set the time restriction so I'd say better safe than sorry. – Alex – 2015-04-08T23:24:01.180

6FWIW I discovered the Windows official "Disk cleanup" tool also leaves anything that was modified within the last week, so I guess it plays it safe. (They could also be required by currently running programs, to be fair). – thomasrutter – 2015-04-09T01:11:28.960

Nothing important is kept there. If some programs use files there, they will be in use / not deletable. If not, the folder can be deleted entirely. – Overmind – 2015-04-17T09:40:49.267

3I always clean my %temp%, no decent program keeps important files there. and you will not be able to delete files that are being used. I just close all apps and programs, delete everything in there and restart. never had an issue my self. – Maher Fattouh – 2016-01-30T01:23:23.590

I just want to know Is windows update use it when next restart? because I want to create it on Ramdisk(create in the memory), it will clean every time power off. I remember windows always continue execute some update progress even after next reboot. – qakmak – 2016-06-14T16:27:48.777

I know of an IDE that keeps "script files" of ad-hoc code to run in "temp" files. And sometimes they get purged. So it loses my code (scripts). It's most annoying. And yes, it's broken behavior, due to bad and invalid design. But it's not like they'll fix it for me. :-/ – Jeff Grigg – 2019-11-25T14:29:26.147

55

Yes, you can. Windows already does it for you when you use the Disk Cleanup tool (cleanmgr.exe) and select the Temporary files checkbox.

Pedro77

Posted 2013-03-26T20:34:37.627

Reputation: 1 367

11it is cleanmgr.exe, so just click start, type cleanmgr and press enter if you don't want to waste time looking for it – Vitas – 2015-01-18T21:09:24.850

17I've done this, and now Disk Cleanup shows 0 bytes for temporary files, but appdata/local/temp is still 2gb – mcmillab – 2016-07-31T21:49:18.237

9I did disk cleanup, and my temp is still 27GB :( – Mooing Duck – 2016-11-30T03:34:38.983

4@MooingDuck try it again but Run it as Admin. – Pedro77 – 2016-11-30T11:45:35.823

This worked for me. – The Vivandiere – 2017-11-29T19:09:50.520

Then click on 'Clean up system files" to list all temporary files. – Efreeto – 2019-05-28T18:31:52.367

26

You can, but I am assuming your intention is to free up disk space. If this is the case you might want to use clean-up instead of doing the process manually. Go to Run and type cleanup:

Enter image description here

Then click Disk Cleanup and choose a drive.

Window will pop up where you will be able to select for deletion of temporary (and other mostly useless) files from multiple locations, not just C:\Users\[Username]\AppData\Local\Temp.

Enter image description here

Matas Vaitkevicius

Posted 2013-03-26T20:34:37.627

Reputation: 963

2Using the Windows disk cleanup feature seems like the safest route. – warriorpostman – 2015-07-06T17:38:47.597

10I'm looking at that interface now and it shows Temporary files at 0 bytes. At the same time I have 21 Gb of files in Local\Temp so I would double check – DroidIn.net – 2015-08-24T15:24:56.827

3Disk Cleanup doesn't do much good for me. Yes they can free some spacce, but they overlook quite a bit, unfortunately – Hoàng Long – 2015-10-20T05:57:15.793

Disk Cleanup normaly leave files that were last modified less than 24 hours ago. – Mr Rubix – 2018-03-30T11:43:34.120

4

In theory, AppData's Temp folder (%TEMP%) is the place for programs to put files that can be deleted immediately after all handles to them are closed. In practice, many programs - including Microsoft's own - violate that guidance. That's why some disk cleanup utilities (notably CCleaner) by default leave files that were last modified less than 24 hours ago. It's almost certainly safe to remove those, and unless you have particularly rickety third-party software, you can probably remove any that aren't in use.

That said, however, I would advise against demolishing the actual Temp folder. It will get recreated periodically, but programs can rely on it being there. I've seen programs that attempt to create files under %TEMP%, expecting the call to always succeed. (For example, attempting to echo stuff > bogusFolder\x.txt will fail if you don't have a folder called bogusFolder.) Therefore, it's best to leave well-known folders where they are.

The same advice (for both the files and the folder) applies to the Temp folder under Windows, though that Temp folder is used only by the system or programs running as administrator. It tends to get full of log files, which can be deleted with wild abandon.

Ben N

Posted 2013-03-26T20:34:37.627

Reputation: 32 973

1

Yes and no.

What I like to do is delete everything in the folder, but not the folder itself. Any files that "require special permission from the administrator" to delete, I leave alone.

This is generally the safest way I can think of when it comes to emptying your Temp folder.

RobotUnderscore

Posted 2013-03-26T20:34:37.627

Reputation: 204

1

Yes, it is safe. I did it many times.

This question arise when we need to wipe-up our hard disk drive. I recommend using WinDirStat which is a disk usage statistics viewer and cleanup tool for various versions of Microsoft Windows.

And check this post: Guide to Freeing up Disk Space under Windows 8.1

racsonp

Posted 2013-03-26T20:34:37.627

Reputation: 21

1

Yes, you can because some of those old files can become corrupt. So if you delete the entire folder nothing bad will happen. All of the ones that you need, the programs will create new ones.

And if you can't delete some then a program you are running is running those temp files so just leave those alone. I do it all the time on my user's machines that file, and the C:\WINDOWS\Temp directory as well.

Eryper

Posted 2013-03-26T20:34:37.627

Reputation: 169

Some apps store important components there, improper though that may be. – apraetor – 2015-02-27T00:22:06.247

0

My advice would be to create a new folder in the temp directory and move any files/folders you want to delete to the new folder, check if everything still works. If you are confident everything is ok you should be safe to delete them. If you run into problems just move the files back to the temp folder again.

Simone M

Posted 2013-03-26T20:34:37.627

Reputation: 11