i have applied this code to clean temp files on windows with vba

Prasad K

Board Regular
Joined
Aug 4, 2021
Messages
189
Office Version
  1. 2016
  2. 2007
Platform
  1. Windows
i have applied this code to clean temp files and windows with excel vba macro

this code is not working i don't know why this code is not working

VBA Code:
Sub CleanTemp()
    On Error Resume Next
    Kill "C:\Windows\Prefetch\*.tmp"
    Kill "C:\Windows\Temp\*.tmp"
    Kill "C:\Users\Prasad\AppData\Local\Temp\*.tmp"
    On Error GoTo 0
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
My guess is that you need to be logged in as administrator to your machine to be able to do that.
Can you delete from the 2 C:\Windows files when you do it manually ?

I would have thought the last line would work.
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: is there any macro to open temp file folder and delete temp files
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: is there any macro to open temp file folder and delete temp files
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
It's not a same question it is different
 
Upvote 0
In what way is it different?
 
Upvote 0
In what way is it different?
ok the vba code should be same & question should be different in both

why i should i asked this code is not working on my excel

if it is wrong to ask i am sorry for that
 
Upvote 0
You have already been warned about cross posting without links. In future make sure you supply the link(s) yourself.
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,148
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top