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 "-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 ">" (
- tsdiscon %%U %verbose%
- )
- )
- endlocal
- goto :eof
- :help
- echo.
- echo %~n0 - disconets all session except the current
- echo.
- echo %~n0 [/V]
- echo.
- echo /V verbose information
- echo.
- echo by Vasil "npocmaka" Arnaudov
- goto :eof
- endlocal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement