Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: How do files in ...\AppData\Local\Temp get deleted?

21 Dec 2015   #1
JohnHa

Windows 7 Home 64 bit
 
 
How do files in ...\AppData\Local\Temp get deleted?

I am debugging an problem with an application which uses ...\AppData\Local\Temp to store its temporary files.

My questions are:

Q1 Does W7 ever automatically delete files from this folder?

Q2 Is each application supposed to delete the files it creates?

Q3 If Q2 is YES, are their known cases where a badly written application goes delete ...\AppData\Local\Temp\*.*? That would cause my problem as it would delete my temporary files.

I ask because the symptom of the problem I am debugging is that the application's temporary files in ...\AppData\Local\Temp suddenly get deleted which causes the application to lose data.

Note that the files being deleted are not "held open by the application" so there is no protection from their being deleted by another program. Also I know that cleaning programs can be scheduled to clean ...\AppData\Local\Temp but I am ignoring that for the moment - I want to know what W7 does.

Thanks


My System SpecsSystem Spec
.
21 Dec 2015   #2
UsernameIssues

W7 Pro SP1 64bit
 
 

> Q1 Does W7 ever automatically delete files from this folder?
Not that I have ever seen.


> Q2 Is each application supposed to delete the files it creates?
In my opinion, apps should cleanup after themselves, but many apps do not.


> Q3 If Q2 is YES, are their known cases where a badly written application goes delete ...\AppData\Local\Temp\*.*? That would cause my problem as it would delete my temporary files.
I don't know of any "normal" apps that delete temp files that were created by other apps. Of course, apps that are designed to delete some or all temp files (e.g. CCleaner) will delete temp file created by other apps.


You can use Process Monitor to determine which app is removing the temp file of interest.

Set a filter for Path > contains > AppData\Local\Temp > Include

If desired, you can be more specific with the filter above. You can include one of the files that holds data of interest. If desired, you can add a a filter to include entries for every temp file of interest.

If need be, you can temporarily exclude the app that writes the data to these temp files. Right click on the app name and select exclude from the context menu. That should let you see any other apps that are acting on the temp files of interest.

If you need to let Process Monitor run for a long time, set a local backing file.
(Menu bar > Files > Backing Files...)

If you need more help using Process Monitor, search YouTube or post your questions here in this thread.


If need be, we can probably come up with a script that will alert you to when the temp files are deleted. Knowing the exact time of deletion might help you find the entries of interest within Process Monitor.
My System SpecsSystem Spec
21 Dec 2015   #3
JohnHa

Windows 7 Home 64 bit
 
 

Thank you. Your reply has confirmed my suspicions.

I have been running some more tests and I found that CCleaner did not delete files - or at least not my application's files - in ...\Local\Temp so I shall have to look elsewhere in the application for my problem.

My initial thought was that it is slightly risky for an application to write temporary data files in such a common location where they can be "deleted by anyone" but on checking I found that the files are only able to be deleted by someone who has, or some application which has, Administrator privilege. Ordinary users only have Read and Execute permissions on my application's files.
My System SpecsSystem Spec
.

21 Dec 2015   #4
Baddog22556

Windows 7
 
 

They are not automatically deleted unless your written app does it or programs like CCleaner
or Disk Cleanup specifically target those temporary files.
My System SpecsSystem Spec
21 Dec 2015   #5
LMiller7

Windows 7 Pro 64 bit
 
 

I don't believe that Windows would ever delete any of this folders contents except when requested by the user. I would consider it highly highly inappropriate to do otherwise. This folder is used by applications and it is their responsibility to manage their one temp files. Applications have varying definitions of what "temporary" means and may expect such files to exist for long periods of time. This is not recommended behavior but some do so.

Quote:
My initial thought was that it is slightly risky for an application to write temporary data files in such a common location where they can be "deleted by anyone" but on checking I found that the files are only able to be deleted by someone who has, or some application which has, Administrator privilege. Ordinary users only have Read and Execute permissions on my application's files.
It's somewhat more complicated than that. A standard user can delete temporary files created by their own applications. An account is considered the owner of files they create and have full control over them, at least in this context. This is good, otherwise an application run under a standard account could not delete it's own temp files. There is nothing to prevent an application from deleting or overwriting files created by other applications run under the same account. Administrators can delete any temp files created by any account, including other administrators.

While an application is running it can lock a temp file for exclusive access. In that case even an admin could not delete them.
My System SpecsSystem Spec
21 Dec 2015   #6
JohnHa

Windows 7 Home 64 bit
 
 

Thank you.

I have done some more work on the problem I am debugging (a word processing application where users sometimes lose the images in their document) and I can now replicate the symptoms exactly.

The application writes the images as individual files, one per image; and the text content etc; to ...\AppData\Local\Temp. The text content etc file is locked as being open, preventing it being deleted; the image files are not so locked. If I manually delete all files in ...\AppData\Local\Temp, simulating clearing \Temp, the text content file remains while the images are deleted. When the document is saved, the text content is OK but the images are lost.

This is exactly what users experience - they save a document and on opening it, some or all of the images are missing. Hence my wondering if something could be deleting the files.
My System SpecsSystem Spec
21 Dec 2015   #7
RolandJS

Windows 7 Professional 64-bit
 
 

Is this computer running any sort of PC-cleaner and/or any sort of bulldog-level privacy-guard software?
My System SpecsSystem Spec
21 Dec 2015   #8
Ztruker

Windows 10 Pro X64
 
 

You can add that specific folder to CCleaner's cleanup list if you want.
My System SpecsSystem Spec
21 Dec 2015   #9
JohnHa

Windows 7 Home 64 bit
 
 

Thank you.

I respond to forum posts from users so I unfortunately have little information about exactly what they did or are doing, or how their PCs are configured. They just report - very occasionally - they have lost images. It has been impossible to reproduce the fault.

I only thought of this as a possible mechanism today and am progressing it. I have about 25,000 WP files on my PC having used the s/w for many years and it has never happened to me, so I am grasping at straws.

I tried CCleaner, which I have, but the as delivered configuration it does not clear the ...\AppData\Local\Temp\ folder. I realise that other cleaning utilities might clear the folder.
My System SpecsSystem Spec
21 Dec 2015   #10
JohnHa

Windows 7 Home 64 bit
 
 

Quote   Quote: Originally Posted by Ztruker View Post
You can add that specific folder to CCleaner's cleanup list if you want.
:-)) That is exactly what I do not want the users to do!!!
My System SpecsSystem Spec
Reply

 How do files in ...\AppData\Local\Temp get deleted?




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
No AppData\Local\Temp\trachme64.dll
On switching on my daughters slow laptop it always comes up with this message. There was a problem starting C:Users\Emily|Appdata\Temp\trachme64.dll The specified module could not be found
Performance & Maintenance
What is C:\Users\PC\AppData\Local\Temp ? :)
While i was exploring windows explorer, i came up to this folder C:\Users\PC\AppData\Local\Temp What does it contain? What are tmp, old, mtx, and text document files? Is it ok to delete this folder? (I don't know what came up to my mind, i just feel i want to delete some stuff on my computer...
General Discussion
System cannot find AppData\Local(\Temp).
There for I am having installation problems. It appears to deleted. What do I do?
Installation & Setup
SSD Optimisation - move Appdata\Local\Temp?
Hi all - just fitted a Kingston SSD and done a clean install of 7UP. In order to minimse read/writes on the drive I have moved the following to other Hdd's: Windows temp Browser caches and temps App scratchdisks and temp files Windows Pagefile (separate partition on other drive) I would...
Performance & Maintenance
AppData>Local>Temp (???) Lost file *&%@!*!!
Hi there System 7 Demigods, So I'm in my email where a buddy sent me a word doc as an attachment that I modified, hit save, and saved to Lord Knows Where.... :cry: The address when I retrace my steps (ever so cautiously) is: <<Users>Name>AppData>Local>Temp Now I can see the Word file...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 16:13.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App