Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. @echo off
  2.  
  3. if "%1"=="" goto help
  4.  
  5. :: Put the work dir here
  6. set "workdir=%1
  7. set "workdir=%workdir:\=\\%"
  8.  
  9. setlocal enableDelayedExpansion
  10. for /f "usebackq tokens=* delims=" %%a in (`
  11. wmic process where 'CommandLine like "%%!workdir!%%" and not CommandLine like "%%RuntimeBroker%%"' get CommandLine^,ProcessId /format:value
  12. `) do (
  13. for /f "tokens=* delims=" %%# in ("%%a") do (
  14. if "%%#" neq "" (
  15. set "%%#"
  16. SET var="%%#"
  17. SET searchVal=ProcessId
  18. SET var|FINDSTR /b "var="|FINDSTR /i %searchVal% >nul
  19. IF ERRORLEVEL 1 (echo.) ELSE (taskkill /pid !ProcessId! /f)
  20. )
  21. )
  22.  
  23. )
  24.  
  25. goto end
  26.  
  27. :help
  28. echo ********************
  29. echo * Example of Usage *
  30. echo ********************
  31. echo.
  32. echo =============================================
  33. echo closeapp \\server\path\test
  34. echo.
  35.  
  36. :end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement