Jump to content

Why I cant delete files in temp folder - window 10.


Recommended Posts

If file is at the moment opened by some application or operating system, it cannot be deleted. Files can be opened in read, write or read-write mode. Files can be opened in shared or exclusive mode. Exclusive mode means no other process can access (open) file. Process holds handle to the file.

You can learn which file is accessed by which process using FileMon or SysInternals.

https://docs.microsoft.com/en-us/sysinternals/

If DLL (dynamic-link library) is opened by LoadLibrary() function it can't be deleted, until the all processes call FreeLibrary() or shutdown. DLL doesn't have to have .dll extension.

 

Link to comment
Share on other sites

I've been using the free version of Ccleaner for almost 15 years ( introduced in 04, I believe ).
I run the system cleaner every time I shut down one of my computers ( about 18, all Win10, except for one Raspbian running RetroPi for old games emulation ), mostly to clean out cookies, and never had an issue.
I run the registry cleaner ( all boxes checked ) every time I install/uninstall software, or MS updates me, and again, I've never had an issue.

Link to comment
Share on other sites

On 6/1/2021 at 7:19 PM, Sensei said:

If file is at the moment opened by some application or operating system, it cannot be deleted. Files can be opened in read, write or read-write mode. Files can be opened in shared or exclusive mode. Exclusive mode means no other process can access (open) file. Process holds handle to the file.

You can learn which file is accessed by which process using FileMon or SysInternals.

https://docs.microsoft.com/en-us/sysinternals/

If DLL (dynamic-link library) is opened by LoadLibrary() function it can't be deleted, until the all processes call FreeLibrary() or shutdown. DLL doesn't have to have .dll extension.

 

The problem is that there are over 100 files in the folder - C:\Users\user_name\AppData\Local\Temp

I can only delete a few of them.

Window 7 did not have the problem. all files in any TEMP folders will be deleted by one click.

Link to comment
Share on other sites

Posted (edited)
1 hour ago, PeterBushMan said:

The problem is that there are over 100 files in the folder - C:\Users\user_name\AppData\Local\Temp

I can only delete a few of them.

Window 7 did not have the problem. all files in any TEMP folders will be deleted by one click.

I have Win7 and also can't delete some files in temp directory. It is normal. Any application can create (and keep access lock to) temporary files by using GetTempPath()/GetTempFileName() functions:

https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha

https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamea

 

Reread what I wrote in the previous post and identify which processes opened these files. And kill these processes/services. If process/service is shutdown, it should release exclusive access lock to temporary file.

 

The real problem would be if files would be really big. *)

You can try:

edit environment variables e.g. change TEMP and TMP from default value:

%USERPROFILE%\AppData\Local\Temp

to something else. e.g. change to Temp2.

Then restart the computer.

Then you should be able to delete old Temp folder with the all contents (because it is no longer used). New temporary files should appear in Temp2 folder instead.

Then rename environment variables back to the original value, and restart the computer once again.

 

*) They can be e.g. automatic updates downloaded from the Internet.

 

Edited by Sensei
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.