-
Notifications
You must be signed in to change notification settings - Fork 0
/
clear.txt
48 lines (26 loc) · 1.1 KB
/
clear.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
The following batch commands are used to delete all your temp, recent and prefetch files on your System.
Save the following code as "Clear.bat" on your local system
*********START CODE************
@ECHO OFF
del /s /f /q %userprofile%\Recent\*.*
del /s /f /q C:\Windows\Prefetch\*.*
del /s /f /q C:\Windows\Temp\*.*
del /s /f /q %USERPROFILE%\appdata\local\temp\*.*
/Below command to Show the folder after deleted files
Explorer %userprofile%\Recent
Explorer C:\Windows\Prefetch
Explorer C:\Windows\Temp
Explorer %USERPROFILE%\appdata\local\temp
*********END CODE************
del won't trigger any dialogs or message boxes. You have a few problems, though:
start will just open Explorer which would be useless. You need cd to change the working directory of your batch file (the /D is there so it also works when run from a different drive):
cd /D %temp%
You may want to delete directories as well:
for /d %%D in (*) do rd /s /q "%%D"
You need to skip the question for del and remove read-only files too:
del /f /q *
so you arrive at:
@echo off
cd /D %temp%
for /d %%D in (*) do rd /s /q "%%D"
del /f /q *