process 개수 check batch file

Estimated reading: 1 minute 12 views

notepad 의 개수를 result.txt file에 저장을 하고

for문으로 해당 문서의 결과를 임의의 변수에 저장을 합니다.

이후 해당 변수의 값이 원하는 개수 이면 정상 아니면 강제 kill하는 script입니다.

for문의 상세한 option은 cmd에서 for /?

를 치시고 확인 하시기 바랍니다.

@echo off

tasklist | find /c "notepad.exe" > c:\result.txt

for /f %%i in (c:\result.txt) do if "%%i" == "4" exit 0

taskkill /F /IM notepad.exe

exit 1

답글 남기기

Chat Icon Close Icon