-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.TXT
288 lines (270 loc) · 16.1 KB
/
README.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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
Search and Kill
1. License
----------
Copyright (c) 2012-2017 Lcferrum
This program comes with no warranty.
You must use this program at your own risk.
Licensed under BSD license - see LICENSE.TXT file for details.
2. About
--------
Search and Kill (SnK) is a console tool that automatically searches for certain
Windows processes and kills them. Search is accomplished according to SnK input
arguments. This tool is mainly designed to be run with keyboard shortcut. This
could be done with SnK HotkeySuite, that was specifically designed for use with
SnK (https://github.com/lcferrum/snk_hotkeysuite), or by using automation
software like AutoHotkey (http://www.autohotkey.com/). Sample AHK script is
included: check out SnKSampleScript.ahk file.
3. Where to get
---------------
You can compile SnK by yourself (refer to COMPILE.TXT that comes with the
sources) or download binary distribution from Sourceforge:
https://sourceforge.net/projects/sandk/files/SnK/
Main project homepage is at GitHub:
https://github.com/lcferrum/snk
4. Usage
--------
Usage (SnK with console output):
SnK [settings_block|swith[:parametres][=argument]] ...
Usage (windowless SnK with dialog output):
SnKh [settings_block|swith[:parametres][=argument]] ...
All swithes and settings blocks are executed sequentially, starting from the
first one. Settings block consists of one or more separate settings combined
together and can be either all-set (+) or all-unset (-) block. All settings
within single settings block and all parametres within single switch are
applied simultaneously. Incorrect swithes, arguments, settings and parametres
are ignored and warning is issued. Switches starting from hash (#) are silently
ignored (may be used as hashtag-like comments). Switches can return result, and
if result is positive - program will stop execution (you can modify this
behaviour with some settings).
Windowless version prints output only in verbose mode via dialog. But you can
always redirect standart output streams (which are still present) to see it
either way. The main advantage of windowless version is that it can be run in
the background where it doesn't interfere with other programs, whereas standart
version will open console window (if not already run from console) which will
get focus and become top-level window. E.g. using /fsc switch in non-windowless
SnK could be unreliable because target process will likely lose it's fullscreen
properties due to emerged console window.
Switches:
/hlp
Print usage information and exit. Can only be
used as first argument, ignored otherwise.
/ver
Print version information and exit. Can only be
used as first argument, ignored otherwise.
/bpp
Make standart Windows 'informational beep' and
continue execution.
/prn=TEXT
Echo-like switch - will print to stdout whatever
passed to it and continue execution.
/sec
Secured execution. Will return positive result if
there is another instance already running that
has executed this switch. Use before other
switches with verbose mode to prevent
accidentiall subsequent execution of program.
/cpu
Kill process with highest cpu load. Will return
positive result if process was found. Can return
negative result only if there were no user
processes running and 'query all processes'
mode was turned off.
/d3d[:simple]
Kill process that uses Direct3D and has highest
cpu load. If 'simple', will use process modules
names to find Direct3D process. Otherwise, will
use description of modules. Simple method is
somewhat less precise but faster. Please check
DetectMatrix.html for more information. Will
return positive result if process was found.
/ogl[:simple]
Kill process that uses OpenGL and has highest cpu
load. If 'simple', will use process modules names
to find OpenGL process. Otherwise, will use
description of modules. Simple method is somewhat
less precise but faster. Please check
DetectMatrix.html for more information. Will
return positive result if process was found.
/gld[:simple]
Kill process that uses Glide and has highest cpu
load. If 'simple', will use process modules names
to find Glide process. Otherwise, will use
description of modules. Simple method is somewhat
less precise but faster. Please check
DetectMatrix.html for more information. Will
return positive result if process was found.
/inr[:plus]
Kill process that is not responding and has
highest cpu load. By default will use standard
Windows procedure (IsHungAppWindow) to check if
application is hung. That works ok for most of
real life cases. If 'plus', will additionally
check if window is answering to SendMessage call.
This will help with artificially hung apps (e.g.
SuspendThread'ed) Will return positive result if
process was found.
/fsc[:anywnd][:primary]
Kill process that is running in fullscreen and
has highest cpu load. Works with multi-monitor
setups. By default only exclusive fullscreen and
borderless windowed processes are checked. If
'anywnd', will check processes with any window
type, borderless or not. If 'primary', will check
only windows that belong to primary display. Will
return positive result if process was found.
/fgd[:anywnd]
Kill process which window is in foreground.
Though there is always a foreground window, this
switch may return nothing if foreground process
has 'non-task' window (has no icon on the task
bar) or doesn't belong to user and 'query all
processes' mode was turned off. If 'anywnd', will
also include 'non-task' windows. Will return
positive result if process was found.
/pth[:full]=WCARDS
Kill process which name matches one of the
wildcards (delimeted by semicolon) and has
highest cpu load. Matching is always
case-insensitive. If 'full', will use full
process path instead of just name. Wildcards use
standart wildcard characters '?' (exactly one
unknown character) and '*' (zero or more unknown
characters). Will return positive result if
process was found.
/mod[:full]=WCARDS
Kill process that has a module which name matches
one of the wildcards (delimeted by semicolon) and
has highest cpu load. Matching is always
case-insensitive. If 'full', will use full
module path instead of just name. Wildcards use
standart wildcard characters '?' (exactly one
unknown character) and '*' (zero or more unknown
characters). Will return positive result if
process was found.
/pid[:parent|=PIDS]
Kill process which PID belongs to PID array and
has highest cpu load. PID array consists of PIDs,
delimeted by comma or semicolon, and can include
descending or ascending ranges. PID must be
decimal (no prefix), hexadecimal ('0x'/'0X'
prefix) or octal ('0' prefix) unsigned integer.
If 'parent', instead of using supplied PID array,
will use paren process PID. Will return positive
result if process was found.
/cmd[:sub][:utf8|:utf16]=FILE
Will load additional commands from file and
continue execution. Encoding is auto-detected
using BOM's. If there is no BOM, it is assumed
that encoding is ANSI or you can force correct
one using 'utf8' ot 'utf16' params. If 'sub',
will execute supplied commands as subroutine.
Settings changed inside subroutine won't
propagade beyond it (further commands won't be
affected) and 'cmd' will return result based on
subroutine execution: positive if subroutine
reached it's end without triggering on any of the
switches and negative otherwise.
/lst[:clrmask|:invmask]
List currently available processes - processes
that are not already terminated, not blacklisted,
within whitelist (if it exists) and non-system
(if +a setting wasn't turned on). If 'clrmask',
will clear blacklist, reset whitelist and show
result. If 'invmask', will swap blacklist with
whitelist and show result. In any case - will
continue execution afterwards.
/psh=ARGUMENT
Push argument to argument stack and continue
execution.
/pop[=ENV_VAR]
Pop argument from argument stack. Popped argument
will be used as argument for the next switch in
case that switch won't supply it's own argument
(empty or not). If ENV_VAR is supplied - argument
will be popped to environment variable ENV_VAR.
In either case execution will continue.
/end
Unconditionally (i.e. ignoring 'ignore' and
'negate' modes) return positive result.
Settings:
+t|-t
Will turn 'test' mode on/off. While in test mode,
switches only display information about found
processes but don't kill them.
+v|-v
Will turn 'verbose' mode on/off. While in verbose
mode, program will prompt user to press 'enter'
before exit.
+a|-a
Will turn 'query all processes' mode on/off.
While in this mode, process with highest cpu load
will be searched among all processes and not just
user processes.
+l|-l
Will turn 'loop' mode on/off. While in this mode,
every switch will be looped until it finally
returns negative result. Overall result will be
posistive if one of the iterations returned
positive result.
+i|-i
Will turn 'ignore' mode on/off. While in this
mode, even if switch returns positive result SnK
execution continues.
+n|-n
Will turn 'negate' mode on/off. While in this
mode, results returned by switches are treated as
opposite ones. If switch is not designed to
return result - nothing happens.
+b|-b
Will turn 'blacklist' mode on/off. While in this
mode, all processes on which switches trigger are
added to blacklist. Blacklisted processes will be
ignored by all switches. This mode automatically
turns on 'query all processes', 'loop', 'ignore'
and 'test' modes on while it is active.
+w|-w
Will turn 'whitelist' mode on/off. While in this
mode, all processes on which switches trigger are
added to whitelist. Switches will query only
whitelisted processes. This mode automatically
turns on 'query all processes', 'loop', 'ignore'
and 'test' modes on while it is active.
+r|-r
Will turn 'recently created sort' mode on/off.
While in this mode, switches, instead of
triggering on process with highest cpu usage,
trigger on last created process.
+m|-m
Will turn 'mute' mode on/off. While in this mode,
all stream output (both stdout and stderr) is
suppressed.
+c|-c
Will turn 'close' mode on/off. While in this mode,
instead of terminating app there SnK will try to
close it in ordinary way. If app won't respond to
close action, it will be terminated.
+e|-e
Will turn 'expand environment variables' mode
on/off. While in this mode, all the environmet
variables passed inside arguments will be
expanded before being passed to switch.
5. Usage example
----------------
Example:
SnK /sec +vt /bpp /d3d /ogl:simple -t /pth="*Skype*"
SnK will do the following in this example:
1) Secure current SnK instance. If there is another secured SnK instance
running already, program will exit without prompting. Otherwise it will
continue execution.
2) Will turn verbose and test mode on.
3) Will make 'informational beep' and continue.
4) Will search for Direct3D processes. Will continue if nothing was found.
Will prompt user to press 'enter' if process was found and then exit.
5) Will search for OpenGL processes using 'simple' method. Will continue if
nothing was found. Will prompt user to press 'enter' if process was found
and then exit.
6) Will turn test mode off.
7) Will search for process with name similar to "Skype" using case-insensitive
compare. Will prompt user to press 'enter' if nothing was found and then
exit. Will kill process and prompt user to press 'enter' if process was
found and then exit.