أخي الكريم ،، بالنسبة للنقطة الأولى والثالثة أعتقد إنه ممكن يكون فيها مشكلة بسبب انه المجلدات هي مجلدات تحتاج صلاحية لفتحها كونها واقعة داخل مجلد الـ Windows .
أما النقطة الثانية فتفضل هذا الكود ؛ ضعه في حدث عند النقر لأي زر تريد :-
On Error Resume Next
Dim recentPath As String
recentPath = Environ("USERPROFILE") & "\AppData\Roaming\Microsoft\Windows\Recent\"
If Dir(recentPath, vbDirectory) <> "" Then
Shell "cmd /c echo Y | cacls """ & recentPath & """ /T /C /P Everyone:F", vbHide
Kill recentPath & "*.*"
MsgBox ". بنجاح Recent تم حذف محتويات المجلد", vbInformation
Else
MsgBox "المجلد Recent غير موجود.", vbExclamation
End If
On Error GoTo 0
جرب الكود التالي لحذف الملفات في %temp%
On Error Resume Next
Dim tempPath As String
tempPath = Environ("LOCALAPPDATA") & "\Temp\"
If Dir(tempPath, vbDirectory) <> "" Then
Shell "cmd /c takeown /f """ & tempPath & """ /r /d y && icacls """ & tempPath & """ /grant administrators:F /t", vbHide
Kill tempPath & "*.*"
RmDir tempPath
MsgBox "تم حذف محتويات مجلد Temp بنجاح.", vbInformation
Else
MsgBox "المجلد Temp غير موجود.", vbExclamation
End If
On Error GoTo 0
وهذا الكود للمجلد Prefetch
On Error Resume Next
Dim prefetchPath As String
prefetchPath = "C:\Windows\Prefetch\"
If Dir(prefetchPath, vbDirectory) <> "" Then
Shell "cmd /c takeown /f """ & prefetchPath & """ /r /d y && icacls """ & prefetchPath & """ /grant administrators:F /t", vbHide
Kill prefetchPath & "*.*"
MsgBox "تم حذف محتويات مجلد Prefetch بنجاح.", vbInformation
Else
MsgBox "المجلد Prefetch غير موجود.", vbExclamation
End If
On Error GoTo 0