-
Notifications
You must be signed in to change notification settings - Fork 25
/
run_tweaks.bat
148 lines (111 loc) · 4.23 KB
/
run_tweaks.bat
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
@echo off
title Cleanup running. Do not close.
cd /d "%~dp0"
REM utf-8 encoding, support russian text
chcp 65001 >nul
REM Run this script with administrative privilegies
if "%1"=="task" goto SKIP_ELEVATE
if "%1"=="ok" goto SKIP_ELEVATE
data\elevate -c %0 ok
exit
:SKIP_ELEVATE
REM In order to make checks invisible code below has been moved to the bootstrap.vbs
if NOT "%1"=="task" goto SKIP_CHECKS
REM Run script every monday and do check that script already runned at this day
SET DAY=%DATE:~0,3%
SET YYYYMMDD=%DATE:~10%%DATE:~4,2%%DATE:~7,2%
IF NOT [%DAY%]==[Mon] EXIT
IF [%DAY%]==[Mon] IF EXIST "%AppData%\Lock_%YYYYMMDD%.lck" EXIT
IF [%DAY%]==[Mon] IF NOT EXIST "%AppData%\Lock_%YYYYMMDD%.lck" (
del "%AppData%\Lock_*.lck" 2>nul
ECHO Script has run %YYYYMMDD% already>>"%AppData%\Lock_%YYYYMMDD%.lck"
)
:SKIP_CHECKS
REM 'start' to use short path
set DATA_DIR=%~dp0data
set CONFIG_DIR=%~dp0config
SET CCLEANER_DIR=%~dp0CCleaner
SET CCLEANER=ccleaner64.exe
SET NIRCMD=nircmd-x64.exe
SET NIRCMD_DIR=%~dp0data
if %PROCESSOR_ARCHITECTURE%==x86 (
SET CCLEANER=ccleaner.exe
SET NIRCMD=nircmd.exe
)
SET CCLEANER=%CCLEANER_DIR%\%CCLEANER%
SET NIRCMD=%NIRCMD_DIR%\%NIRCMD%
if not exist "%CONFIG_DIR%" mkdir "%CONFIG_DIR%"
REM Regular task command line. 'windows-tweaks' should be a full path
REM wscript.exe "<windows-tweaks>\data\bootstrap.vbs" "<windows-tweaks>\run_tweaks.bat" task
REM Valid schedule types: MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT.
REM Example: schtasks /Create /TN "Cleanup Task" /SC WEEKLY /TR "\"%0\" task" /RL HIGHEST /F
REM REM workaround with absent option 'run task as soon as possible'
REM REM NOTE: can't combine all params in one schtasks command
REM schtasks /Create /TN "Cleanup Task" /xml "data/Cleanup Task Idle.xml" /F >nul
REM SET OLD_TASK_COMMAND=\"%0\" task
REM SET TASK_COMMAND=wscript.exe \"%~dp0data\bootstrap.vbs\" \"%0\" task
REM schtasks /Change /TN "Cleanup Task" /TR "%TASK_COMMAND%" /RU Users /RL HIGHEST >nul
REM REM ru fix: all default users and groups are localized on non-english locales
REM schtasks /Change /TN "Cleanup Task" /TR "%TASK_COMMAND%" /RU Пользователи /RL HIGHEST 2>nul
echo ============================
echo Preparing for the cleanup...
echo ============================
echo Creating Restore point (you could easily revert changes)...
Wmic.exe /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "%DATE%", 100, 7 2>nul >nul
echo =========================
echo Beginning junk cleanup...
echo =========================
echo Closing processes that may interfere with cleanup tasks...
echo Closing Chrome...
start /wait %NIRCMD% closeprocess chrome.exe
echo Running CCleaner...
start /wait %CCLEANER% /auto
REM restore processes
REM start /d "%ProgramFiles(x86)%\Google\Chrome\Application" chrome.exe --start-maximized --disk-cache-size=104857600
REM start "" "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Google Chrome.lnk"
echo ==============================
echo Beginning main cleanup part...
echo ==============================
echo Detecting OS...
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
if "%version%" == "6.1" goto WINDOWS_7
if "%version%" == "6.3" goto WINDOWS_8_1
if "%version%" == "6.2" goto WINDOWS_8
if "%version%" == "10.0" goto WINDOWS_10
goto WINDOWS_END
endlocal
:WINDOWS_10
echo Windows 10 detected
pushd win10-tweaks
call run-addons.bat ok
popd
goto WINDOWS_END
:WINDOWS_8_1
:WINDOWS_8
echo Windows 8 detected
pushd win8-tweaks
call win8-clean.bat
popd
goto WINDOWS_END
:WINDOWS_7
echo Windows 7 detected
pushd win7-tweaks
call run-addons.bat ok
popd
goto WINDOWS_END
:WINDOWS_END
if exist "%CONFIG_DIR%\defrag_disks_n.cfg" goto NO_DEFRAG
if exist "%CONFIG_DIR%\defrag_disks_y.cfg" goto START_DEFRAG
SET /P AREYOUSURE=Defragment your disks (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO NO_DEFRAG
:START_DEFRAG
echo. > "%CONFIG_DIR%\defrag_disks_y.cfg"
echo Starting defragmentation...
defrag /c >nul 2>nul
goto EXIT_DEFRAG
:NO_DEFRAG
echo. > "%CONFIG_DIR%\defrag_disks_n.cfg"
:EXIT_DEFRAG
echo ====================
echo Finishing cleanup...
echo ====================