Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- if "%1"=="" goto help
- :: Put the work dir here
- set "workdir=%1
- set "workdir=%workdir:\=\\%"
- setlocal enableDelayedExpansion
- for /f "usebackq tokens=* delims=" %%a in (`
- wmic process where 'CommandLine like "%%!workdir!%%" and not CommandLine like "%%RuntimeBroker%%"' get CommandLine^,ProcessId /format:value
- `) do (
- for /f "tokens=* delims=" %%# in ("%%a") do (
- if "%%#" neq "" (
- set "%%#"
- SET var="%%#"
- SET searchVal=ProcessId
- SET var|FINDSTR /b "var="|FINDSTR /i %searchVal% >nul
- IF ERRORLEVEL 1 (echo.) ELSE (taskkill /pid !ProcessId! /f)
- )
- )
- )
- goto end
- :help
- echo ********************
- echo * Example of Usage *
- echo ********************
- echo.
- echo =============================================
- echo closeapp \\server\path\test
- echo.
- :end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement