-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKill.bat
258 lines (246 loc) · 8.23 KB
/
Kill.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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
@echo off
::
:: Creator: ShadowWhisperer
:: Github: https://github.com/ShadowWhisperer
:: Created: Sometime before 2015
:: Updated: 12/09/2024
::
::
:: Works with Windows XP Pro and all other verions after.
:: Taskkill and tasklist are not part of XP Home. You can downlaod from above my github page, and
:: place them "C:\Windows\System32" They were taken from a pro version of XP when this script was first written.
::
:: Gets a list of running proccesses
:: Sorts by unique *Redundant to kill the name multiple times, /t/f forces all closed
:: Check if name should be skipped
:: - Force kills
:: - Skips
::
:: Services
:: Gets a list of running services
:: Check if name should be skipped
:: - Force stop
:: - Skips
::
:#Kill Processes (1)
del "%tmp%\1.txt" >nul 2>&1
del "%tmp%\2.txt" >nul 2>&1
del "%tmp%\3.txt" >nul 2>&1
:: WMIC
if exist "C:\Windows\System32\wbem\wmic.exe" (
WMIC /OUTPUT:"%temp%\1.txt" path win32_process get Caption /format:csv
for /f "tokens=1,* delims=," %%A in ('type "%temp%\1.txt"') do echo %%~nxB|find "."|find /v "svchost.exe">>"%temp%\3.txt"
sort "%temp%\3.txt" /O "%temp%\3.txt"
setlocal enabledelayedexpansion
for /f "tokens=*" %%a in ('type "%temp%\3.txt"') do (
if "%%a" neq "!last!" (
echo %%a>>"%temp%\2.txt"
set "last=%%a"
)
)
endlocal
) else (
:: PowerShell
powershell -NoProfile -Command ^
"Get-Process | Where-Object { $_.Path -ne $null } | ForEach-Object { [System.IO.Path]::GetFileName($_.Path) } | Out-File -FilePath '%tmp%\1.txt' -Encoding ASCII"
powershell -NoProfile -Command ^
"Get-Content '%tmp%\1.txt' | Sort-Object -Unique | ForEach-Object { if ($_ -ne 'svchost.exe' -and $_ -ne '') { $_ } } | Out-File -FilePath '%tmp%\2.txt' -Encoding ASCII"
)
for /f "skip=1 tokens=*" %%a in ('type "%tmp%\2.txt"') do (
if not "%%a"=="AWCC.Service.exe" (
if not "%%a"=="cmd.exe" (
if not "%%a"=="CMGShieldSvc.exe" (
if not "%%a"=="conhost.exe" (
if not "%%a"=="csrss.exe" (
if not "%%a"=="Dell.SecurityFramework.Agent.exe" (
if not "%%a"=="Dell.SecurityFramework.Console.exe" (
if not "%%a"=="Dell.SecurityFramework.LocalServer.exe" (
if not "%%a"=="devmonsrv.exe" (
if not "%%a"=="DFSSvc.exe" (
if not "%%a"=="dllhost.exe" (
if not "%%a"=="dwm.exe" (
if not "%%a"=="EmsService.exe" (
if not "%%a"=="EmsServiceHelper.exe" (
if not "%%a"=="explorer.exe" (
if not "%%a"=="fontdrvhost.exe" (
if not "%%a"=="LsaIso.exe" (
if not "%%a"=="lsass.exe" (
if not "%%a"=="lsm.exe" (
if not "%%a"=="MDLCSvc.exe" (
if not "%%a"=="MsMpEng.exe" (
if not "%%a"=="NisSrv.exe" (
if not "%%a"=="obexsrv.exe" (
if not "%%a"=="PRSvc.exe" (
if not "%%a"=="sc.exe" (
if not "%%a"=="services.exe" (
if not "%%a"=="sihost.exe" (
if not "%%a"=="smss.exe" (
if not "%%a"=="taskhost.exe" (
if not "%%a"=="taskmgr.exe" (
if not "%%a"=="Taskmgr.exe" (
if not "%%a"=="wininit.exe" (
if not "%%a"=="winlogon.exe" (
if not "%%a"=="WMIC.exe" (
if not "%%a"=="WmiPrvSE.exe" (
if not "%%a"=="WUDFCompanionHost.exe" (
taskkill /im "%%a" /f /t >nul 2>&1
)))))))))))))))))))))))))))))))))))))
:#Stop Services (1)
del "%tmp%\1.txt" >nul 2>&1
del "%tmp%\2.txt" >nul 2>&1
del "%tmp%\3.txt" >nul 2>&1
for /f "tokens=1,*" %%a in ('sc queryex ^|find "SERVICE_NAME"^|find /v "cbdhsvc_"^|find /v "CDPUserSvc_"^|find /v "WpnUserService_"') do echo %%b>>"%tmp%\2.txt"
sort "%tmp%\2.txt" /O "%tmp%\2.txt"
setlocal enabledelayedexpansion
for /f "tokens=*" %%a in ('type "%tmp%\2.txt"') do (
if "%%a" neq "!last!" (
echo %%a>>"%tmp%\3.txt"
set "last=%%a"
)
)
endlocal
for /f "tokens=*" %%a in ('type "%tmp%\3.txt"') do (
if not "%%a"=="Appinfo" (
if not "%%a"=="Browser" (
if not "%%a"=="CryptSvc" (
if not "%%a"=="DcomLaunch" (
if not "%%a"=="Dhcp" (
if not "%%a"=="eventlog" (
if not "%%a"=="FontCache" (
if not "%%a"=="gpsvc" (
if not "%%a"=="ibmpmsvc" (
if not "%%a"=="netprofm" (
if not "%%a"=="Netman" (
if not "%%a"=="NlaSvc" (
if not "%%a"=="nsi" (
if not "%%a"=="PlugPlay" (
if not "%%a"=="Power" (
if not "%%a"=="ProfSvc" (
if not "%%a"=="RpcEptMapper" (
if not "%%a"=="RpcSs" (
if not "%%a"=="SamSs" (
if not "%%a"=="Schedule" (
if not "%%a"=="Themes" (
if not "%%a"=="Winmgmt" (
if not "%%a"=="wudfsvc" (
if not "%%a"=="Wlansvc" (
if not "%%a"=="WlanSvc" (
if not "%%a"=="IBMPMSVC" (
if not "%%a"=="BFE" (
if not "%%a"=="EventLog" (
if not "%%a"=="Dnscache" (
if not "%%a"=="WinHttpAutoProxySvc" (
if not "%%a"=="servicesAppXSvc" (
if not "%%a"=="BITS" (
if not "%%a"=="BrokerInfrastructure" (
if not "%%a"=="camsvc" (
if not "%%a"=="CDPSvc" (
if not "%%a"=="ClipSVC" (
if not "%%a"=="CoreMessagingRegistrar" (
if not "%%a"=="DiagTrack" (
if not "%%a"=="DispBrokerDesktopSvc" (
if not "%%a"=="DisplayEnhancementService" (
if not "%%a"=="DoSvc" (
if not "%%a"=="DPS" (
if not "%%a"=="DsmSvc" (
if not "%%a"=="DusmSvc" (
if not "%%a"=="EventSystem" (
if not "%%a"=="iphlpsvc" (
if not "%%a"=="KeyIso" (
if not "%%a"=="LanmanServer" (
if not "%%a"=="LanmanWorkstation" (
if not "%%a"=="lfsvc" (
if not "%%a"=="LicenseManager" (
if not "%%a"=="lmhosts" (
if not "%%a"=="LSM" (
if not "%%a"=="mpssvc" (
if not "%%a"=="NcbService" (
if not "%%a"=="NgcCtnrSvc" (
if not "%%a"=="PcaSvc" (
if not "%%a"=="PushToInstall" (
if not "%%a"=="RasMan" (
if not "%%a"=="SEMgrSvc" (
if not "%%a"=="SENS" (
if not "%%a"=="SensrSvc" (
if not "%%a"=="SgrmBroker" (
if not "%%a"=="SSDPSRV" (
if not "%%a"=="SstpSvc" (
if not "%%a"=="StateRepository" (
if not "%%a"=="SysMain" (
if not "%%a"=="SystemEventsBroker" (
if not "%%a"=="TimeBrokerSvc" (
if not "%%a"=="TokenBroker" (
if not "%%a"=="TrkWks" (
if not "%%a"=="UserManager" (
if not "%%a"=="UsoSvc" (
if not "%%a"=="VaultSvc" (
if not "%%a"=="Wcmsvc" (
if not "%%a"=="WdiServiceHost" (
if not "%%a"=="WPDBusEnum" (
if not "%%a"=="WpnService" (
if not "%%a"=="wscsvc" (
sc stop "%%a" >nul 2>&1
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
:#Kill Processes (2)
del "%tmp%\1.txt" >nul 2>&1
del "%tmp%\2.txt" >nul 2>&1
del "%tmp%\3.txt" >nul 2>&1
:: WMIC
if exist "C:\Windows\System32\wbem\wmic.exe" (
WMIC /OUTPUT:"%temp%\1.txt" path win32_process get Caption /format:csv
for /f "tokens=1,* delims=," %%A in ('type "%temp%\1.txt"') do echo %%~nxB|find "."|find /v "svchost.exe">>"%temp%\3.txt"
sort "%temp%\3.txt" /O "%temp%\3.txt"
setlocal enabledelayedexpansion
for /f "tokens=*" %%a in ('type "%temp%\3.txt"') do (
if "%%a" neq "!last!" (
echo %%a>>"%temp%\2.txt"
set "last=%%a"
)
)
endlocal
) else (
:: PowerShell
powershell -NoProfile -Command ^
"Get-Process | Where-Object { $_.Path -ne $null } | ForEach-Object { [System.IO.Path]::GetFileName($_.Path) } | Out-File -FilePath '%tmp%\1.txt' -Encoding ASCII"
powershell -NoProfile -Command ^
"Get-Content '%tmp%\1.txt' | Sort-Object -Unique | ForEach-Object { if ($_ -ne 'svchost.exe' -and $_ -ne '') { $_ } } | Out-File -FilePath '%tmp%\2.txt' -Encoding ASCII"
)
for /f "skip=1 tokens=*" %%a in ('type "%tmp%\2.txt"') do (
if not "%%a"=="AWCC.Service.exe" (
if not "%%a"=="cmd.exe" (
if not "%%a"=="CMGShieldSvc.exe" (
if not "%%a"=="conhost.exe" (
if not "%%a"=="csrss.exe" (
if not "%%a"=="Dell.SecurityFramework.Agent.exe" (
if not "%%a"=="Dell.SecurityFramework.Console.exe" (
if not "%%a"=="Dell.SecurityFramework.LocalServer.exe" (
if not "%%a"=="devmonsrv.exe" (
if not "%%a"=="DFSSvc.exe" (
if not "%%a"=="dllhost.exe" (
if not "%%a"=="dwm.exe" (
if not "%%a"=="EmsService.exe" (
if not "%%a"=="EmsServiceHelper.exe" (
if not "%%a"=="explorer.exe" (
if not "%%a"=="fontdrvhost.exe" (
if not "%%a"=="LsaIso.exe" (
if not "%%a"=="lsass.exe" (
if not "%%a"=="lsm.exe" (
if not "%%a"=="MDLCSvc.exe" (
if not "%%a"=="MsMpEng.exe" (
if not "%%a"=="NisSrv.exe" (
if not "%%a"=="obexsrv.exe" (
if not "%%a"=="PRSvc.exe" (
if not "%%a"=="sc.exe" (
if not "%%a"=="services.exe" (
if not "%%a"=="sihost.exe" (
if not "%%a"=="smss.exe" (
if not "%%a"=="taskhost.exe" (
if not "%%a"=="taskmgr.exe" (
if not "%%a"=="Taskmgr.exe" (
if not "%%a"=="wininit.exe" (
if not "%%a"=="winlogon.exe" (
if not "%%a"=="WMIC.exe" (
if not "%%a"=="WmiPrvSE.exe" (
if not "%%a"=="WUDFCompanionHost.exe" (
taskkill /im "%%a" /f /t >nul 2>&1
))))))))))))))))))))))))))))))))))))))