You are not logged in.
Pages: 1
Because I've found that TSKILL could be useful too.... :-)
Despite the TASKKILL is far more powerful ,TSKILL has also some advantages:
1. Home editions of Windows do not have TASKKILL
2. TSKILL can filter processes by session id ,while TASKKILL can do it only by user name. Which is useful when more than one person work on a remote machine with same credentials.
3. TSKILL can be used against remote machines if the current user has permissions to do it
One annoying thing about TSKILL is that it does not recognize process name if it has ".exe" suffix.
Here's a simple script that I'm using to kill all processes on a terminal by name except for the current user (could be easy remade to kill the processes only for current user)
@echo off
:sesskill
setlocal
rem =========================
rem == parsing parameters ==
set "exe_name=%~1"
echo %exe_name%| findstr /i /e ".exe" >nul 2>&1 && set "exe_name=%exe_name:~0,-4%"
for %%H in ( /h -h /help -help "" ) do (
if /I "%~1" equ "%%~H" goto :help
)
shift
for %%V in (/V /v v V) do (
if "%~1" EQU "%%V" (
set "verbose=/V"
)
)
rem =========================
setlocal enabledelayedexpansion
for /f "skip=1 tokens=1,2,3" %%S in ('query user') do (
set "current_user=%%S"
if "!current_user:~0,1!" NEQ ">" (
for /f "tokens=2 delims= " %%M in ('tasklist ^| find "%exe_name%"') do (
tskill "%%M" %verbose% /ID:%%U
)
)
)
endlocal
goto :eof
:help
echo.
echo %~n0 - kills all processes by given name except for the current session
echo.
echo %~n0 executable [/V]
echo.
echo executable executable to be terminated.
echo /V verbose information
echo.
goto :eof
endlocal
Offline
2. TSKILL can filter processes by session id ,while TASKKILL can do it only by user name. Which is useful when more than one person work on a remote machine with same credentials.
3. TSKILL can be used against remote machines if the current user has permissions to do it
Checked on Windows 7 Pro and 2003 SP2; your mileage may vary:
C:\>taskkill /?
TASKKILL [/S system [/U username [/P [password]]]]
{ [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]
Description:
This tool is used to terminate tasks by process id (PID) or image name.
Parameter List:
/S system Specifies the remote system to connect to.
/U [domain\]user Specifies the user context under which the
command should execute.
/P [password] Specifies the password for the given user
context. Prompts for input if omitted.
8< snip >8
Filters:
Filter Name Valid Operators Valid Value(s)
----------- --------------- -------------------------
STATUS eq, ne RUNNING |
NOT RESPONDING | UNKNOWN
IMAGENAME eq, ne Image name
PID eq, ne, gt, lt, ge, le PID value
SESSION eq, ne, gt, lt, ge, le Session number.
8< snip >8
Last edited by bluesxman (29 Aug 2013 08:41)
cmd | *sh | ruby | chef
Offline
Yes....
So the only place where you'll have a use of TSKILL are the windows home editions....
Offline
Pages: 1