Skip to content

Instantly share code, notes, and snippets.

@npocmaka
Created November 15, 2017 14:59
Show Gist options
  • Save npocmaka/c9d07d720228145ed7b628ec0a653e04 to your computer and use it in GitHub Desktop.
Save npocmaka/c9d07d720228145ed7b628ec0a653e04 to your computer and use it in GitHub Desktop.
Kills chromedriver and chrome browsers started by selenium framework
@echo off
setlocal EnableDelayedExpansion
set count=0
for /f "usebackq tokens=* delims=" %%a in (`wmic process where "name='chrome.exe' and CommandLine like '%%--enable-automation%%'" get ProcessID /Format:value`) do (
for /f "tokens=1,2 delims==" %%A in ("%%a") do (
set /a count=count+1
set "%%A[!count!]=%%B"
)
)
for /L %%# in (1;1;%count%) do (
taskkill /pid !processId[%%#]! /f 1>nul 2>&1
)
taskkill /im chromed* /f >nul 2>&1
endlocal
for %%x in (%cmdcmdline%) do if /i "%%~x"=="/c" pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment