-
Notifications
You must be signed in to change notification settings - Fork 1
/
RegSystemLibraries.cmd
234 lines (180 loc) · 7.55 KB
/
RegSystemLibraries.cmd
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
@echo off
SetLocal EnableExtensions EnableDelayedExpansion
set MAX_Processes_Count=30
set MAX_Timout=80
set timer=0
chcp 866 >NUL
cd /d "%~dp0"
title RegSystemLibraries by Dragokas ver.1.1
echo ‘ªà¨¯â ¢®ááâ ®¢«¥¨ï ॣ¨áâà 樨 á¨á⥬ëå ¡¨¡«¨®â¥ª
echo.
call :CheckPrivilegies
color 1A
:settings
:: ஢¥àª ¢¥àᨨ Ž‘
echo ‚¥àá¨ï Ž‘:
ver
:: ஢¥àª à §à冷á⨠Ž‘
Set "xOS=AMD64"& If "%PROCESSOR_ARCHITECTURE%"=="x86" If Not Defined PROCESSOR_ARCHITEW6432 Set "xOS=x86"
echo [ %xOS% ]
echo.
echo â® ¬®¦¥â § ïâì ¤® 10 ¬¨ãâ ¨ ¡®«¥¥.
echo à®æ¥áá®à ¬®¦¥â ¡ëâì £à㦥 ¤® 100 %%.
echo „«ï ãáª®à¥¨ï ®¯¥à 樨 ¢à¥¬¥® ®âª«îç¨â¥ ⨢¨àãᮥ Ž.
echo.
echo -------------------------------------------------
echo ’¥ªã騥 áâனª¨:
echo.
echo - Ž¤®¢à¥¬¥® à ¡®â ¥â ¯à®æ¥áᮢ: %MAX_Processes_Count%
echo - ’ ©¬ ãâ § ¢¥àè¥¨ï ¯à®æ¥áá : %MAX_Timout% ᥪ.
echo -------------------------------------------------
echo.
echo.
echo ¦¬¨â¥ «î¡ãî ª« ¢¨èã çâ®¡ë ¯à¨ïâì áâனª¨ ¨ ç âì ॣ¨áâà æ¨î,
echo ¨«¨ N çâ®¡ë ¨§¬¥¨âì áâனª¨.
echo.
set ch=
set /p ch=
if /i "%ch%" neq "N" if /i "%ch%" neq "â" goto begin
echo.
echo ‚¢¥¤¨â¥ ®£à ¨ç¥¨¥ ª®«-¢ ®¤®¢à¥¬¥® à ¡®â îé¨å ¯à®æ¥áᮢ
set /p MAX_Processes_Count=" (¤«ï á« ¡ëå ¬ è¨ ãª §ë¢ ©â¥ ¬¥ì襥 ç¨á«®): "
echo.
echo ‚¢¥¤¨â¥ â ©¬ ãâ ¤«ï § ¢¥àè¥¨ï ¯à®æ¥áá
set /p MAX_Timout=" (¤«ï á« ¡ëå ¬ è¨ ãª §ë¢ ©â¥ ¡®«ì襥 ç¨á«®): "
cls
goto settings
:begin
cd /d "%~dp0"
echo ®¦ «ã©áâ , ¯®¤®¦¤¨â¥ ...
echo.
taskkill /F /T /IM regsvr32.exe >NUL 2>NUL
:: ¤«ï ¯à®£à¥áá¡ à
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%A in (1) do rem"') do set "DEL=%%a"
:: ¥£¨áâà æ¨ï ¡¨¡«¨®â¥ª, ¥®¡å®¤¨¬ëå ¤«ï ª®à४⮩ à ¡®âë áªà¨¯â
echo ç â ॣ¨áâà æ¨ï ®á®¢ëå ¡¨¡«¨®â¥ª ¨ WMI ...
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\advapi32.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\kernel32.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\msvcrt.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\user32.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\ntdll.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\ole32.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\version.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\mpr.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\oleaut32.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\secur32.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\ws2_32.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\framedynos.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\netapi32.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\dbghelp.dll /s
start "" /min "%SystemRoot%\System32\regsvr32.exe" %SystemRoot%\System32\shlwapi.dll /s
echo .dll - %SystemRoot%\System32\wbem\
echo.
For /F %%F in ('dir /B /A-D "%SystemRoot%\System32\wbem\*.dll"') do (
start "" /min "%SystemRoot%\System32\regsvr32.exe" "%SystemRoot%\System32\wbem\%%F" /s
)
call :Wait
call :Wait
call :Wait
call :Wait
call :Wait
echo OK.
call :RegLib "%SystemRoot%\System32\*.dll"
call :RegLib "%SystemRoot%\System32\*.ocx"
call :RegLib "%SystemRoot%\System32\*.tlb"
if %xOS%==AMD64 (
call :RegLib "%SystemRoot%\SysWOW64\wbem\*.dll"
call :RegLib "%SystemRoot%\SysWOW64\*.dll"
call :RegLib "%SystemRoot%\SysWOW64\*.ocx"
call :RegLib "%SystemRoot%\SysWOW64\*.tlb"
)
echo.
pause
exit /B
:CheckPrivilegies
:: ¯à®¢¥àª «¨ç¨ï ¯à ¢ ¤¬¨¨áâà â®à
>NUL 2>NUL reg add HKLM\Software\Test /v Test /F && (
>NUL 2>NUL reg delete HKLM\Software\Test /v Test /F) || (
echo ‡ ¯ãáâ¨â¥ áªà¨¯â ¯à ¢®© ª®¯ª®© ¬ëè¨ "Žâ ¨¬¥¨ ¤¬¨¨áâà â®à "
echo.
pause
exit
)
Exit /B
:RegLib [_in_®«ë© ¯ãâì ª ¡¨¡«¨®â¥ª¥. „®¯ã᪠¥âáï ¬ ᪠.]
echo ®¤áç¥â ¡¨¡«¨®â¥ª %~x1 - %~dp1
SetLocal
set PercentView=0
set libs=0
:: § ¯¨áë¢ î ¢á¥ ¨¬¥ ä ©«®¢ ¢ ¬ áᨢ
For /F "delims=" %%F in ('dir /B /A-D-L "%~1"') do set /a libs+=1& set lib.!libs!=%~dp1%%F
echo [ %libs% ]
if %libs%==0 goto :RegLib_exit
set LastProcess=%MAX_Processes_Count%
:: ¥á«¨ ª®«-¢® ¡¨¡«¨®â¥ª ¬¥ìè¥ ç¨á« ®£à ¨ç¥¨ï
if %MAX_Processes_Count% GTR %libs% set LastProcess=%libs%
set /p "x=ணà¥áá... 0%%"<NUL
:: ‡ ¯ã᪠¯¥à¢®© ¯ à⨨ ¯à®æ¥áᮢ ॣ¨áâà 樨
call :RunProcesses 1 %LastProcess%
:RegLib_loop
:: ‘«¥¤¨¬ § ª®«-¢®¬
call :WaitForReady "regsvr32.exe" TotalP
:: Œ®¦® § ¯ãáâ¨âì ¯à®æ¥áᮢ
set /a AvailP=%MAX_Processes_Count% - %TotalP%
:: ®¬¥à ¯¥à¢®£® ¯à®æ¥áá , ®â ª®â®à®£® ᥩç á ¬®¦® § ¯ã᪠âì
set /a FirstProcess=%LastProcess% + 1
:: ®¬¥à ¯®á«¥¤¥£® ¯à®æ¥áá , ¤® ª®â®à®£® ᥩç á ¬®¦® § ¯ã᪠âì
set /a LastProcess+=%AvailP%
:: …᫨ # ¯®á«¥¤¥£® § ¯ã᪠¥¬®£® ¡®«ìè¥ ®¡é¥£® ª®«-¢ ¡¨¡«¨®â¥ª - ãᥪ ¥¬
if %LastProcess% GTR %libs% set LastProcess=%libs%
::echo TotalP=%TotalP%, FirstProcess=%FirstProcess%, LastProcess=%LastProcess%
:: Š®¥çë© # >= ç «ì®£® # - § ¯ã᪠¥¬ ¯à®æ¥ááë ¯® 楯®çª¥
if %LastProcess% GEQ %FirstProcess% call :RunProcesses %FirstProcess% %LastProcess%
:: …᫨ ®¡à ¡ ⢠¥¬ë¥ ¯à®æ¥ááë § ª®ç¨«¨áì, ¥®¡å®¤¨¬ëå ¤«ï ®¡à ¡®âª¨ â ª¦¥ ¥â - ¢ë室¨¬
if %TotalP%==0 if %FirstProcess% GTR %LastProcess% goto RegLib_exit
goto RegLib_loop
:RegLib_exit
EndLocal &:: ®ç¨á⪠¬ áᨢ
echo %DEL%%DEL%%DEL%%DEL%100 %%
Exit /B
:RunProcesses [# ¯¥à¢®£® ¯à®æ¥áá ] [# ¯®á«¥¤¥£® ¯à®æ¥áá ]
:: ”ãªæ¨ï § ¯ã᪠¥â ¥áª®«ìª® ¯à®æ¥áᮢ ¢ 䮥.
:: ’ॡã¥â £«®¡ «ìëå ¯¥à¥¥¬ëå:
:: PercentView - ¤®«¦¥ ¡ëâì ¨¨æ¨ «¨§¨à®¢ ç¨á«®¬ 0.
:: libs - ®¡é¥¥ ª®«-¢® ¡¨¡«¨®â¥ª. ¥ ¤®«¦® à ¢ïâìáï 0.
For /L %%C in (%~1 1 %~2) do start "Stream %%C" /min "%SystemRoot%\System32\regsvr32.exe" !lib.%%C! /s
set /a NextPercent=%PercentView% / 10 * 10 + 10
set /a CurPercent=%~1 * 100 / %libs%
::echo CurPercent=%CurPercent%, NextPercent=%NextPercent%
if %CurPercent% GEQ %NextPercent% (set PercentView=%NextPercent%& set /p "x=%DEL%%DEL%%DEL%%NextPercent%%%"<NUL)
::echo %~1 - %~2
Exit /B
:WaitForReady [_in_ˆ¬ï ¯à®æ¥áá ] [_out_ãä¥à ¤«ï åà ¥¨ï ª®«-¢ § ¯ãé¥ëå ¯à®æ¥áᮢ]
:: Ž¦¨¤ ¥â § ¢¥à襨ï 㪠§ ®£® ç¨á« ¯à®æ¥áᮢ, ¯®á«¥ 祣® ¢®§¢à é ¥â ã¯à ¢«¥¨¥
:: …᫨ ¯à®æ¥áá ¥ ¡ë« § ¢¥àè¥ § 㪠§ ®¥ ç¨á«® ᥪã¤, ¯à¨ã¤¨â¥«ì® § ¢¥àè ¥â ¥£®
::
:: „®¯®«¨â¥«ì® âॡã¥â £«®¡ «ìëå ¯¥à¥¬¥ëå:
:: CurPID - PID ⥪ã饣® ¯à®æ¥áá
:: MAX_Timout - ¬ ªá¨¬ «ìë© â ©¬ ãâ ¤«ï ¯à®æ¥áá , ª®â®àë© § ¢¨á
:: call :Wait
Set /A PIDs=0
:: ¥à¥ç¨á«ïî ¢á¥ ¯à®æ¥ááë. ஢¥àïî, 㪠§ «¨ ¤«ï ª ¦¤®£® ¨§ PID ᢮© timer.
:: …᫨ ¥ 㪠§ , § ®èã ¢ ¬ áᨢ TimeOut.PID = â ©¬¥à.
:: …᫨ 㪠§ , ᢥàïî à §¨æã ¬¥¦¤ã ¨¬ ¨ â ©¬¥à®¬. …᫨ ¯à¥¢ëè ¥â ¤®¯ãáâ¨¬ë© - 㡨¢ î ¯à®æ¥áá ¨ ¢ë᢮¡®¦¤ î í«¥¬¥â ¬ áᨢ .
For /F "tokens=1,2 delims=," %%A in ('tasklist /FI "imagename EQ %~1" /FO CSV /NH 2^>NUL ^| find /i "%~1"') do (
rem echo %%A - %%B
if not Defined TimeOut.%%~B (
set TimeOut.%%~B=%timer%
set /A PIDs+=1
) else (
set /a diff=%timer% - !TimeOut.%%~B!
if !diff! GEQ %MAX_Timout% (taskkill /F /PID %%~B >NUL 2>NUL& set TimeOut.%%~B=) else (set /A PIDs+=1)
)
)
set %~2=%PIDs%
call :Wait
Exit /B
:Wait { void }
ping -n 2 127.1 >NUL
set /a timer+=1&:: ᥢ¤®â ©¬¥à
Exit /B