ImDeepWithWindows

kill.cmd

Jul 4th, 2020
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. @goto :batch
  2.  
  3. *****************************************************************************************
  4. I made this as a short-hand verssion of the "taskkill" command
  5. that automatically recognizes wild-cards (*) in the Task-Name
  6.  
  7. in the normal "taskkill" command to use a wild-card in the task's file-name
  8. you cant just use the normal image-name switch (/im FileNa*.exe)
  9. you instead have to use the filter switch (/fi "IMAGENAME eq FileNa*.exe")
  10. and thats an unnecessary amount of extra amount of typing for something simple
  11. so I made this quick thing as a Command-Line AddOn Command to be more convenient
  12. *****************************************************************************************
  13.  
  14. :batch
  15. @echo off
  16. if "%*"=="" (
  17. echo.
  18. echo.type: "%~n0 /?" for the help menu
  19. echo.
  20. goto :eof
  21. )
  22. if "%*"=="-?" goto :help
  23. if "%*"=="/?" goto :help
  24. if "%*"=="/?" goto :help
  25. if /I "%*"=="/install" goto :InstallAsCommandPromptCommand
  26. if /I "%*"=="-install" goto :InstallAsCommandPromptCommand
  27. echo.
  28. taskkill /f /fi "IMAGENAME eq %*"
  29. echo.
  30. goto :eof
  31.  
  32. :InstallAsCommandPromptCommand
  33. echo.
  34. echo.installing %~n0 as a command-line command ...
  35. if not exist "%userprofile%\AddedCommandLineCommands" (
  36. mkdir "%userprofile%\AddedCommandLineCommands"
  37. attrib +h +s -r "%userprofile%\AddedCommandLineCommands"
  38. reg add HKCU\Environment /v "AddedCommandLineCommandsLocation" /t "reg_sz" /d "%userprofile%\AddedCommandLineCommands" /f >nul
  39. reg add HKCU\Environment /v "PATH" /t "reg_sz" /d "%PATH%;%userprofile%\AddedCommandLineCommands" /f >nul
  40. )
  41. copy /y "%~dpnx0" "%userprofile%\AddedCommandLineCommands\%~nx0" >nul
  42. echo.
  43. echo.
  44. echo %~n0 has been added as a command-line command for the logged in user
  45. echo.changes will take effect at next log-in
  46. echo.
  47. echo.
  48. goto :eof
  49.  
  50. :help
  51. for /f "tokens=2 skip=4" %%A in ('mode con: /status') do set "WindowColumns=%%A" & goto :GotColumnCount
  52. :GotColumnCount
  53. set "CharLine="
  54. setlocal EnableDelayedExpansion
  55. for /L %%A in (1,1,%WindowColumns%) do set "CharLine=!CharLine!="
  56. setlocal DisableDelayedExpansion
  57. endlocal
  58. echo.
  59. echo %CharLine%
  60. echo %~n0
  61. echo %CharLine%
  62. echo.
  63. echo.[SYNTAX]:
  64. echo.
  65. echo.
  66. echo %~n0 FileName.exe - ends the task named "FileName.exe"
  67. echo %~n0 FileNa* - ends every task who's name starts with "FileNa"
  68. echo %~n0 /? - show help menu
  69. echo %~n0 -? - show help menu
  70. echo %~n0 /install - installs "%~n0" as a universtal Command-Line command for the currently logged on windows user
  71. echo %~n0 -install - installs "%~n0" as a universtal Command-Line command for the currently logged on windows user
  72. echo.
  73. echo.
Add Comment
Please, Sign In to add comment