Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- :sesskill
- rem -- kills all processes by given name except for the current session
- rem -- by Vasil "npocmaka" Arnaudov
- setlocal
- set exe_name=%~1
- rem =========================
- rem == parsing parameters ==
- set exe_name=%~1
- if "%~1" EQU "" (
- goto :help
- )
- if "%~1" EQU "-h" (
- goto :help
- )
- if "%~1" EQU "/h" (
- goto :help
- )
- if "%~1" EQU "?" (
- goto :help
- )
- if "%~1" EQU "/?" (
- 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.
- echo by Vasil "npocmaka" Arnaudov
- goto :eof
- endlocal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement