Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @goto :batch
- *****************************************************************************************
- I made this as a short-hand verssion of the "taskkill" command
- that automatically recognizes wild-cards (*) in the Task-Name
- in the normal "taskkill" command to use a wild-card in the task's file-name
- you cant just use the normal image-name switch (/im FileNa*.exe)
- you instead have to use the filter switch (/fi "IMAGENAME eq FileNa*.exe")
- and thats an unnecessary amount of extra amount of typing for something simple
- so I made this quick thing as a Command-Line AddOn Command to be more convenient
- *****************************************************************************************
- :batch
- @echo off
- if "%*"=="" (
- echo.
- echo.type: "%~n0 /?" for the help menu
- echo.
- goto :eof
- )
- if "%*"=="-?" goto :help
- if "%*"=="/?" goto :help
- if "%*"=="/?" goto :help
- if /I "%*"=="/install" goto :InstallAsCommandPromptCommand
- if /I "%*"=="-install" goto :InstallAsCommandPromptCommand
- echo.
- taskkill /f /fi "IMAGENAME eq %*"
- echo.
- goto :eof
- :InstallAsCommandPromptCommand
- echo.
- echo.installing %~n0 as a command-line command ...
- if not exist "%userprofile%\AddedCommandLineCommands" (
- mkdir "%userprofile%\AddedCommandLineCommands"
- attrib +h +s -r "%userprofile%\AddedCommandLineCommands"
- reg add HKCU\Environment /v "AddedCommandLineCommandsLocation" /t "reg_sz" /d "%userprofile%\AddedCommandLineCommands" /f >nul
- reg add HKCU\Environment /v "PATH" /t "reg_sz" /d "%PATH%;%userprofile%\AddedCommandLineCommands" /f >nul
- )
- copy /y "%~dpnx0" "%userprofile%\AddedCommandLineCommands\%~nx0" >nul
- echo.
- echo.
- echo %~n0 has been added as a command-line command for the logged in user
- echo.changes will take effect at next log-in
- echo.
- echo.
- goto :eof
- :help
- for /f "tokens=2 skip=4" %%A in ('mode con: /status') do set "WindowColumns=%%A" & goto :GotColumnCount
- :GotColumnCount
- set "CharLine="
- setlocal EnableDelayedExpansion
- for /L %%A in (1,1,%WindowColumns%) do set "CharLine=!CharLine!="
- setlocal DisableDelayedExpansion
- endlocal
- echo.
- echo %CharLine%
- echo %~n0
- echo %CharLine%
- echo.
- echo.[SYNTAX]:
- echo.
- echo.
- echo %~n0 FileName.exe - ends the task named "FileName.exe"
- echo %~n0 FileNa* - ends every task who's name starts with "FileNa"
- echo %~n0 /? - show help menu
- echo %~n0 -? - show help menu
- echo %~n0 /install - installs "%~n0" as a universtal Command-Line command for the currently logged on windows user
- echo %~n0 -install - installs "%~n0" as a universtal Command-Line command for the currently logged on windows user
- echo.
- echo.
Add Comment
Please, Sign In to add comment